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)
 QUERY

Author  Topic 

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-08-17 : 04:58:19
I have table like this..

A b c d Flag
1 10 20 30 0
2 10 20 40 0
3 10 20 50 1
4 10 20 60 0
5 10 20 70 0
6 10 20 80 0
7 10 20 90 1



I need these three records so the Delimitor is Flag = 1

1 10 20 30 0
2 10 20 40 0
3 10 20 50 1

Please help on this..

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-17 : 05:02:26
this ?

select *
from yourtable t
where t.A <= (select min(A) from yourtable x where x.Flag = 1)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-17 : 05:03:23
try like this
declare @i int

select @i = min(a) from tablename where flag = 1

select * from tablename where a <= @i
Go to Top of Page

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-08-17 : 05:06:25
Hi

Can i use like this..

select * from tablename where a <= (SELECT MIN(A) FROM tablename where flag = 1)
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-17 : 05:07:22
yes
Go to Top of Page

WoodHouse
Posting Yak Master

211 Posts

Posted - 2009-08-17 : 05:07:41
Hi
Thanks khtan&Bklr
sorry already khtan was posted.......:)-
Go to Top of Page
   

- Advertisement -