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 |
|
jfieck
Starting Member
6 Posts |
Posted - 2005-06-02 : 17:45:27
|
| Hello, I have what I hope is an easy query that I can't seem to get. Consider this table:--------------------------- TIME -- TYPE ---------------------------- 4:00 -- AM -- 5:00 -- AM -- 5:00 -- PM ---------------------------I need a query that see that there are two rows that have the same TIME value and only retuns one of them. Either of them will do. The aceptable out come would be either of these:--------------------------- TIME -- TYPE ---------------------------- 4:00 -- AM -- 5:00 -- AM ---------------------------or--------------------------- TIME -- TYPE ---------------------------- 4:00 -- AM -- 5:00 -- PM ---------------------------If anyone can help with this it would be appriciated. Thanks. |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2005-06-02 : 18:10:23
|
| SELECT DISTINCT Time, TypeFROM ... |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-06-02 : 18:11:59
|
| SELECT [Time], MAX(Type)FROM YourTableGROUP BY [Time]Tara |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-06-02 : 18:12:30
|
quote: Originally posted by SamC SELECT DISTINCT Time, TypeFROM ...
DISTINCT won't work because the TYPE is different. They aren't duplicate rows.Tara |
 |
|
|
jfieck
Starting Member
6 Posts |
Posted - 2005-06-02 : 18:17:40
|
| This acually doesn't work. I had tried this first. It still returns both lines. I think because the TYPE values are different it makes each row distinct. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-06-02 : 18:18:50
|
| Ummm, did you see my solution?Tara |
 |
|
|
jfieck
Starting Member
6 Posts |
Posted - 2005-06-02 : 18:25:53
|
| Sorry Tara, I didn't see your reply before I sent mine. Thanks. |
 |
|
|
|
|
|