troubleshooting Question

Using ROWCOUNT in subquery of Sybase tables with PHP via ODBC

Avatar of smetterd
smetterdFlag for United States of America asked on
Sybase DatabasePHPSQL
3 Comments1 Solution922 ViewsLast Modified:
See the line where I am trying to use ROWCOUNT. It throws an error in an otherwise-working query.

In my (normal) development with LAMP stack, I would just use the LIMIT clause but that throws an error too.

Any help appreciated. Thank you.
SELECT DISTINCT
'13' AS mk16_district_identifier,
'031912' AS tea_district_identifier,
'0' AS active_alternative,
' ' AS alternative_campus,
('031912'+trim(rsccc.SR_STU_ENROLL.CAMPUS_ID)) AS home_campus,
trim(rsccc.SR_STU_ENROLL.NAME_L) AS NameLast,
trim(rsccc.SR_STU_ENROLL.NAME_F) AS NameFirst,
trim(rsccc.SR_STU_ENROLL.NAME_M) AS NameMiddle,
' ' AS NameSuffix,
(SELECT trim(rsccc.SR_STU_DEMO.STU_ID)) AS StudId,
' ' AS LastReportedPEIMS_id,
(SELECT trim(rsccc.SR_STU_ENROLL.STATE_STU_ID)) AS Ssn,
trim(rsccc.SR_STU_DEMO.SEX) AS Sex,
(left(rsccc.SR_STU_DEMO.DOB,4)+'-'+substring(rsccc.SR_STU_DEMO.DOB,5,2)+'-'+right(rsccc.SR_STU_DEMO.DOB,2)) as Birthday,
left(rsccc.SR_STU_ENROLL.DT_ENTRY,4)+'-'+substring(rsccc.SR_STU_ENROLL.DT_ENTRY,5,2)+'-'+right(rsccc.SR_STU_ENROLL.DT_ENTRY,2) as OrigEntryDateCurrYear,
trim(rsccc.SR_STU_ENROLL.GRD_LVL) AS CurrentGradeLevel,
' ' AS placedInGrade,
' ' AS promotedToGrade,
'Y' AS FreeReducedLunchElig,
trim(rsccc.SR_STU_DEMO.ETHN) AS Ethnicity,
' ' AS GradesOfRetentionPK4,
' ' AS GradesOfRetention58,
trim(rsccc.SR_STU_ENROLL.NAME_L+' '+rsccc.SR_STU_ENROLL.NAME_F+' '+rsccc.SR_STU_ENROLL.NAME_M) AS NameFull,
trim(rsccc.SR_STU_ENROLL.STATUS_CD) AS Status,
' ' AS sped,
' ' AS speech_therapy,
' ' AS sped_setting_id,
' ' AS gt,
' ' AS lep,
' ' AS esl,
' ' AS bilingual,
' ' AS MigrInd,
' ' AS homeLanguage_id,
trim(rsccc.SR_STU_DEMO_PEIMS.MSRTS_ID_NBR) AS MSRTS_ID_Number,
' ' AS ParentPrefix,
(SET ROWCOUNT 1 SELECT trim(rsccc.SR_PARENT.NAME_L+' '+rsccc.SR_PARENT.NAME_F+' '+rsccc.SR_PARENT.NAME_M))) AS ParentName,
(SELECT trim(rsccc.SR_PARENT.STR_NBR+' '+rsccc.SR_PARENT.STR_NAME+' '+rsccc.SR_PARENT.APT_NBR)) AS ParentReside,
(SELECT trim(rsccc.SR_PARENT.CITY)) AS ParentCtyst,
(SELECT trim(rsccc.SR_PARENT.STATE_CD)) AS ParentState,
(SELECT trim(rsccc.SR_PARENT.ZIP) ) AS ParentZip5,
(SELECT trim(rsccc.SR_PARENT.PHONE_AREA_CD+rsccc.SR_PARENT.PHONE_NBR)) AS Hphone,
(SELECT trim(rsccc.SR_PARENT.PHONE_AREA_CD+rsccc.SR_PARENT.PHONE_NBR)) AS Mphone,
'N' AS TextsFromSchoolhouseOK,
' ' AS ParentMobileCarrier,
(SELECT trim(rsccc.SR_PARENT.EMAIL) ) AS ParentEmail
FROM
rsccc.SR_STU_DEMO
INNER JOIN rsccc.SR_STU_ENROLL ON rsccc.SR_STU_ENROLL.SCH_YR = rsccc.SR_STU_DEMO.SCH_YR AND rsccc.SR_STU_ENROLL.STU_ID = rsccc.SR_STU_DEMO.STU_ID
INNER JOIN rsccc.SR_PARENT ON rsccc.SR_PARENT.SCH_YR = rsccc.SR_STU_ENROLL.SCH_YR AND rsccc.SR_PARENT.STU_ID = rsccc.SR_STU_ENROLL.STU_ID
INNER JOIN rsccc.SR_STU_DEMO_PEIMS ON rsccc.SR_PARENT.STU_ID = rsccc.SR_STU_DEMO_PEIMS.STU_ID AND rsccc.SR_PARENT.SCH_YR = rsccc.SR_STU_DEMO_PEIMS.SCH_YR
WHERE
			rsccc.SR_STU_ENROLL.SCH_YR = '2012' AND
			rsccc.SR_STU_ENROLL.ACTIVE_CD = 1 AND
			rsccc.SR_STU_ENROLL.STATUS_CD < 4
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros