dbTalk Databases Forums  

Aggregate function in ASA 9

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Aggregate function in ASA 9 in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Robin
 
Posts: n/a

Default Aggregate function in ASA 9 - 11-22-2004 , 03:34 AM






In ASA 6 this select worked correctly

SELECT T1.ID, DESCR, min(DATE) as MINDAT,STATE
FROM T1, T2
WHERE T1.ID=T2.ID AND MNDAT is not null G
GROUP BY T1.ID, DESCR,STATE
ORDER BY DESCR

In ASA 9 the select returns this error:

Invalid use of an aggregate function
SQLCODE=-150, ODBC 3 State="42000"
Line 1, column 1

What is wrong?

Thanks.



Reply With Quote
  #2  
Old   
Dmitri
 
Posts: n/a

Default Re: Aggregate function in ASA 9 - 11-22-2004 , 03:46 AM






"Robin" <. (AT) iol (DOT) it> wrote:

Quote:
In ASA 6 this select worked correctly

SELECT T1.ID, DESCR, min(DATE) as MINDAT,STATE
FROM T1, T2
WHERE T1.ID=T2.ID AND MNDAT is not null G
GROUP BY T1.ID, DESCR,STATE
ORDER BY DESCR
Unfortunately, ASA6 allowed some syntax errors to slip through; ASA9
query parser is more strict.

Quote:
In ASA 9 the select returns this error:

Invalid use of an aggregate function
SQLCODE=-150, ODBC 3 State="42000"
Line 1, column 1

What is wrong?
This should work:

SELECT T1.ID, DESCR, min(DATE) as MINDAT,STATE
FROM T1, T2
WHERE T1.ID=T2.ID AND
GROUP BY T1.ID, DESCR,STATE
HAVING MINDAT is not null // note this
ORDER BY DESCR

Dmitri.




Reply With Quote
  #3  
Old   
Robin
 
Posts: n/a

Default Re: Aggregate function in ASA 9 - 11-22-2004 , 04:25 AM



Hi Dmitri.

You solved my problem.

Thank you so much.

Robin

"Dmitri" <NOdimSPAM (AT) mail15 (DOT) com> ha scritto nel messaggio news:41a1b58e (AT) forums-1-dub (DOT) ..
Quote:
"Robin" <. (AT) iol (DOT) it> wrote:

In ASA 6 this select worked correctly

SELECT T1.ID, DESCR, min(DATE) as MINDAT,STATE
FROM T1, T2
WHERE T1.ID=T2.ID AND MNDAT is not null G
GROUP BY T1.ID, DESCR,STATE
ORDER BY DESCR

Unfortunately, ASA6 allowed some syntax errors to slip through; ASA9
query parser is more strict.

In ASA 9 the select returns this error:

Invalid use of an aggregate function
SQLCODE=-150, ODBC 3 State="42000"
Line 1, column 1

What is wrong?

This should work:

SELECT T1.ID, DESCR, min(DATE) as MINDAT,STATE
FROM T1, T2
WHERE T1.ID=T2.ID AND
GROUP BY T1.ID, DESCR,STATE
HAVING MINDAT is not null // note this
ORDER BY DESCR

Dmitri.





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.