×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




The following sql statement won't compile... cannot identify A1, A2, A3, A4,
A5 in the order by clause... What am i missing?

C/exec sql
C+ DECLARE R2CSR CURSOR FOR
C+
C+ SELECT MPMRS, CLSUPR, ROUND(AVG(NULLIF(A1,0)),0) AS A1,
C+ ROUND(AVG(NULLIF(A2,0)),0) AS A2, ROUND(AVG(NULLIF(A3,0)),0) AS A3,
C+ ROUND(AVG(NULLIF(A4,0)),0) As A4, ROUND(AVG(NULLIF(A5,0)),0) AS A5
C+
C+ From (SELECT MPMRS, CLSUPR, MPDATE, ROUND(AVG(NULLIF(MPOVSA,0)),0)
C+ AS A1, ROUND(AVG(NULLIF(MPI5TMS,0)),0) AS A2,
C+ ROUND(AVG(NULLIF(MP#ATTS,0)),0) AS A3,
C+ ROUND(AVG(NULLIF(MP#INSTS,0)),0) As A4,
C+ ROUND(AVG(NULLIF(MP#SCPS,0)),0) AS A5
C+
C+ FROM MRSSTATSPF JOIN CSRCLVLPF ON MPMRS = CLCSR AND MPPGRP = CLLGRP
C+
C+ WHERE MPDATE >= :YYYYMMDD3 AND
C+ MPDATE <= :YYYYMMDD AND MPPGRP = :WKGROUP AND
C+ MPDETL = 'D' AND (NOT ( MPCLVL = 4 AND MPRVIA = ' ') ) AND (NOT (
C+ MPCLVL = 5 AND MPRVIA = ' ') ) AND CLTITC >= 10 AND CLTITC <= 30
C+ AND CLTERMDATE IS NULL Group By mpMrs,CLSUPR,MPDATE) As avgList
C+
C+ Group By mpMrs,CLSUPR
C+ ORDER BY
C+ (Case When :WKSTARDSC = 'OVERALL AVERAGE' Then A1
C+ When :WKSTARDSC = 'i5 SCREEN TIME' Then A2
C+ When :WKSTARDSC = '# OF ACCOUNTS ATTEMPTED' Then A3
C+ When :WKSTARDSC = '# OF TOTAL INSTRUMENTS' Then A4
C+ When :WKSTARDSC = '# OF SCREENS COMPLETED' Then A5 End) DESC
C/end-exec




Thanks,

Jay Vaughn
Senior I5 Programmer/Analyst
RateWatch
(P) 251.209.8968
www.rate-watch.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.