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.
| Author |
Topic |
|
rezak
Starting Member
2 Posts |
Posted - 2010-02-04 : 18:29:15
|
| Hi I'm sure exactly how to word this but i'm trying to figure out if it's possible to select a row depending on a value in a field. For example if you had the following tabledate value----------------02/01/2010 p02/02/2010 f02/02/2010 p02/03/2010 f02/04/2010 f02/04/2010 p02/04/2010 p02/05/2010 p02/05/2010 pthe result i'm looking for would be date value----------------02/01/2010 p02/02/2010 f02/03/2010 f02/04/2010 f02/05/2010 pso basically in the data there can be multiples of one date but value can be only two entries 'p' or 'f'. however the result set needs to filter this down to only one day based on the value. if a day has multiple entries with some being 'p' others as 'f', the 'f' record would be only be showing, such as the case in 02/04/2010. if multiple 'p' for one day shows only one would be in the results (same as 'f'), such as case 02/05/2010 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-04 : 20:51:44
|
[code]select *from( select *, row_no = row_number() over(partition by date order by value) from yourtable) dwhere d.row_no = 1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
rezak
Starting Member
2 Posts |
Posted - 2010-02-05 : 09:44:44
|
| Thank you good sir! Been stuck with that for awhile. |
 |
|
|
|
|
|