Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with subquery

Status
Not open for further replies.

TheNewbie81

Technical User
Feb 12, 2007
15
IE
hi,

I have what i thought was a simple inner query ( new to SQL), i want to first return all records where the time is between a and b and then query the results to find num. i cant see whats wrong with it, any ideas?

Code:
SELECT NUM FROM CC_SESSION_TABLE 
WHERE SESSION_NUM = 'ggsn9811;107;125;6668' and REQUEST_NUM ='0'IN ( SELECT NUM FROM CC_SESSION_TABLE
WHERE LAST_EVENT_TIMESTAMP 
BETWEEN TO_DATE('20100812184200','yyyy-mm-dd hh24:mi:ss') AND TO_DATE('20100812184600','yyyy-mm-dd hh24:mi:ss'));

I am getting an error which says ORA-00933: SQL command not properly ended. can't seem to figure out why it wont work, both queries work on their own. any tips or comments would be gratefully accepted :)



 
Your problem is the "='0'". If this is a separate condition, then you need to separate it from your subquery. Something like
Code:
SELECT NUM 
  FROM CC_SESSION_TABLE 
 WHERE SESSION_NUM = 'ggsn9811;107;125;6668' 
   AND REQUEST_NUM ='0' 
   AND REQUEST_NUM IN (SELECT NUM 
                         FROM CC_SESSION_TABLE
                        WHERE LAST_EVENT_TIMESTAMP BETWEEN TO_DATE('20100812184200','yyyy-mm-dd hh24:mi:ss') 
                                                               AND TO_DATE('20100812184600','yyyy-mm-dd hh24:mi:ss')
                       );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top