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 |
DaveGKeller
Starting Member
10 Posts |
Posted - 2008-06-19 : 13:18:39
|
Hello. I have a table that has multiple for multiple people along with 2 other fields (int). Here is example of the data in the table:The periods are just place holders (couldn't figure out how to format)eID......in......out 2.........3.......11 2.........1........2 3.........4........5 2.........7.......10 7.........2.......11 4.........3........7 2.........4.......15 2.........3........6 2.........3........8 8.........2.......18 2........13.......5 4........21......25 3........11......15 7.........9.......11 2.........1........7What I would like to do is be able to get a listing of distinct eIDs along with the lowest number from in (min?) and the highest number from out(max?). I can get distinct eID and min and max but I don't know how to get all in one statement. Please excuse if this is very simple to do but sql is not something I do a lot.With data from above what I would like to get is (ordered by eID ascending, the min(in) and max(out):2 - 1 - 153 - 4 - 124 - 3 - 257 - 2 - 118 - 2 - 18Thank you. I will keep trying and if I figure out I will post back here. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-19 : 13:23:24
|
[code]SELECT eID,MIN(in),MAX(out)FROM TableGROUP BY eIDORDER BY eID[/code] |
 |
|
|
|
|