order by and group by clause [message #35932] |
Wed, 24 October 2001 13:04 |
Brian
Messages: 38 Registered: October 1999
|
Member |
|
|
I am converting some Sybase embeded sql code to Oracle embaded sql code. I have the following embeded code in a c file. I am getting an error on my ORDER by clause. I am at a lose as to what I am doing wrong. If someone could point out the flaw that would be great. Thanks in advance.
EXEC SQL
INSERT INTO TICKET_SUMMARY_RANGE
("SITE_ID","WON","BET",
"PLAYED","M_CASHIN","START_TS","END_TS")
SELECT SITE_ID, SUM(CREDITS_WON),
SUM(CREDITS_BET),
SUM(TICKETS_PLAYED),
0, :begin_timestamp, :end_timestamp
FROM DAILY_SUMMARY
WHERE DATA_TIMESTAMP BETWEEN :begin_timestamp
AND :end_timestamp
GROUP BY DAILY_SUMMARY.SITE_ID, FORM_NUMBER
ORDER BY DAILY_SUMMARY.SITE_ID ASC, FORM_NUMBER
ASC;
----------------------------------------------------------------------
|
|
|
|
Re: order by and group by clause [message #35944 is a reply to message #35932] |
Thu, 25 October 2001 03:36 |
Hans
Messages: 42 Registered: September 2000
|
Member |
|
|
I think the reason is that in the selectlist no column FORM_NUMBER exists
which appears in the order by clause.
INSERT INTO TICKET_SUMMARY_RANGE
("SITE_ID","WON","BET", "PLAYED","M_CASHIN","START_TS","END_TS")
SELECT
SITE_ID,
SUM(CREDITS_WON),
SUM(CREDITS_BET),
SUM(TICKETS_PLAYED),
0,
:begin_timestamp,
:end_timestamp
FROM DAILY_SUMMARY
WHERE DATA_TIMESTAMP BETWEEN :begin_timestamp AND :end_timestamp
GROUP BY DAILY_SUMMARY.SITE_ID, FORM_NUMBER
ORDER BY DAILY_SUMMARY.SITE_ID ASC, <b>FORM_NUMBER</b>
----------------------------------------------------------------------
|
|
|