Home » SQL & PL/SQL » SQL & PL/SQL » SQL command not properly ended
SQL command not properly ended [message #292717] Wed, 09 January 2008 13:31 Go to next message
tomukaz
Messages: 16
Registered: December 2007
Junior Member
4th message now

[Updated on: Wed, 09 January 2008 14:59]

Report message to a moderator

Re: Little select question [message #292721 is a reply to message #292717] Wed, 09 January 2008 14:03 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Post your Oracle version, your table structure (I don't access an unknown site), a test case, the result for this test case and a better specification (what does mean "some workers from one shop sold all milk due some period"?)

Regards
Michel
Re: Little select question [message #292727 is a reply to message #292717] Wed, 09 January 2008 14:28 Go to previous messageGo to next message
touchy501
Messages: 4
Registered: January 2008
Location: Georgia
Junior Member
Try this....it should work...
Razz

select price * sold from
(select mil_bottle_price as price from milk),
(select count(*) as sold from recepies, workers
where rec_work_id=wor_id
and rec_shop_id=6267
and wor_nr in (12345,45468,66666,77777,88888)
and rec_made_date >= to_date( '2007.01.01', 'YYYY.MM.DD')
and rec_sold_date <= to_date( '2007.11.30', 'YYYY.MM.DD'))
Re: Little select question [message #292728 is a reply to message #292717] Wed, 09 January 2008 14:38 Go to previous messageGo to next message
tomukaz
Messages: 16
Registered: December 2007
Junior Member
Heh, rewrote stuff, because fotgot some id's and join function:

SELECT sum(milk.mil_bottle_price) FROM  
JOIN milk ON recepies.rec_id = milk.mil_rec_id 
JOIN workers ON recepies.wor_id = workers.wor_id 
WHERE wor_nr IN (12345,66666,77777) 
AND rec_shop_id = 6267 
AND rec_made_date >= TO_DATE( '2007.01.01', 'YYYY.MM.DD')
 AND rec_sold_date <= TO_DATE( '2007.11.30', 'YYYY.MM.DD');


but I get:
ERROR at line 2:
ORA-00933: SQL command not properly ended
(that's from first JOIN)

...?

table stucture:

 Workers:
 ---------
 wor_id
 wor_nr


 Milk:
 ----------------
 mil_rec_id
 mil_bottle_price


 Recepies:
 -------------
 rec_id
 rec_made_date
 rec_sold_date
 rec_shop_id
 rec_wor_id

[Updated on: Wed, 09 January 2008 14:49] by Moderator

Report message to a moderator

Re: Little select question [message #292825 is a reply to message #292728] Thu, 10 January 2008 00:05 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Please do not remove your post after people reacted to it. It makes the whole thread unreadable.
Previous Topic: Select - how to get the value of the last row for each key
Next Topic: function is said to be return only one value but ....?
Goto Forum:
  


Current Time: Sun Dec 04 18:37:31 CST 2016

Total time taken to generate the page: 0.10198 seconds