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 2005 Forums
 Transact-SQL (2005)
 select data from table

Author  Topic 

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-10-14 : 03:00:53
Hi ..
Here is my table format

id price merchant updated_date
93691 0.00 waterfilterexchange 14/10/10
93691 0.00 J&R 14/10/10
93691 17.57 Amazon.com 14/10/10
93692 17.57 J&R 14/10/10
93692 0.00 Amazon.com 14/10/10
93692 0.00 waterfilterexchange 14/10/10
93691 0.00 waterfilterexchange 8/10/10
93691 0.00 J&R 8/10/10
93691 17.57 Amazon.com 8/10/10
93692 17.57 J&R 8/10/10
93692 0.00 Amazon.com 8/10/10
93692 0.00 waterfilterexchange 8/10/10
93693 0.00 Amazon.com 8/10/10
93693 0.00 shop 8/10/10
93692 17.57 J&R 7/10/10
93692 0.00 Amazon.com 7/10/10
93692 0.00 waterfilterexchange 7/10/10

I want to select the details of waterfilterexchange if id matches then all the details must be selected..
condition here last 7 days record only selected..
output
93691 0.00 waterfilterexchange 14/10/10
93691 0.00 J&R 14/10/10
93691 17.57 Amazon.com 14/10/10
93692 17.57 J&R 14/10/10
93692 0.00 Amazon.com 14/10/10
93692 0.00 waterfilterexchange 14/10/10
93691 0.00 waterfilterexchange 8/10/10
93691 0.00 J&R 8/10/10
93691 17.57 Amazon.com 8/10/10
93692 17.57 J&R 8/10/10
93692 0.00 Amazon.com 8/10/10
93692 0.00 waterfilterexchange 8/10/10
93693 0.00 Amazon.com 8/10/10

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-14 : 04:26:48
Try this:

Select id,price,merchant, updated_date from yourtable where id in
(Select id from YourTable where updated_date >= dateadd(d,-7,dateadd(d,datediff(d,0,getdate()),0))
and merchant ='waterfilterexchange'
)
Go to Top of Page

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-10-14 : 05:32:19
Tx for your reply ..I'll report the answer..
Go to Top of Page

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-10-14 : 06:15:10
Thank you ..I got my required output ..
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-14 : 06:21:32
quote:
Originally posted by jafrywilson

Thank you ..I got my required output ..



You are welcome
Go to Top of Page
   

- Advertisement -