Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Comparing date feilds in SQLSERVER

Author  Topic 

Jakdb
Starting Member

11 Posts

Posted - 2011-09-21 : 09:06:02
Hi,

I am trying to run the below query and i am failing to retrive the order numbers with status messages below,

SELECT o.orderNumber FROM [dbo].[Order] o WHERE (SELECT ose.Date AS dateofstatus FROM [Order]o
JOIN dbo.OrderStatusEntry AS OSE ON OSE.Order_id=o.ID
WHERE ose.StatusTo IN ('Audited','Waiting')) >= (SELECT ose.Date AS dateofstatus FROM [Order]o
JOIN dbo.OrderStatusEntry AS OSE ON OSE.Order_id=o.ID
WHERE ose.StatusTo IN ('Audited','Waiting'))


when i run the query it's failing due to more than one row retrived.
Please help.

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2011-09-21 : 09:35:23
Hello,

If you could, please post some sample data and a desired result set and someone will be able to help you more quickly.

TIA/
Go to Top of Page

Jakdb
Starting Member

11 Posts

Posted - 2011-09-21 : 09:39:29
Hi,
Thanks for reply
Could you please find the below link,

http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/a330f1cf-f006-422b-821b-999b90655ae3

i explained the reqirment
Go to Top of Page

rajarajan
Starting Member

48 Posts

Posted - 2011-09-21 : 10:44:21
CAN U GIVE SOME SAMPLE .
Go to Top of Page

Jakdb
Starting Member

11 Posts

Posted - 2011-09-21 : 11:25:04
Hi raj,

Please look into the above pasted link, example was higlited with explanation.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2011-09-21 : 12:40:52
The error message means that one or both of the subqueries in your WHERE clause are returning more than one row.

Your query doen't make any logical sense, so you should follow the suggestions of the other posters, and provide the table definitions, sample data, and expected output.





CODO ERGO SUM
Go to Top of Page

Jakdb
Starting Member

11 Posts

Posted - 2011-09-21 : 14:15:49
Hi Michael,

Could you please verify the link pasted above, it has the explanation with ddl of the table, and sameple order data,
Go to Top of Page
   

- Advertisement -