Home » SQL & PL/SQL » SQL & PL/SQL » order by and group by clause
order by and group by clause [message #35932] Wed, 24 October 2001 13:04 Go to next message
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 #35934 is a reply to message #35932] Wed, 24 October 2001 15:07 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
i think order by is not allowed there. remove order by clause and try...

----------------------------------------------------------------------
Re: order by and group by clause [message #35944 is a reply to message #35932] Thu, 25 October 2001 03:36 Go to previous message
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>      


----------------------------------------------------------------------
Previous Topic: converting a pl/sql rocedure into an exe file or any OS file
Next Topic: propblem with array
Goto Forum:
  


Current Time: Fri Mar 29 10:14:06 CDT 2024