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 |
|
gblack
Starting Member
2 Posts |
Posted - 2007-11-26 : 12:22:36
|
| I have a table that is about 1.5M records of helpdesk ticket entries. Each ticket may have many entries. What I want to do is pull the first record for each ticket. So if a ticket has 20 entires... I want to get the entire first record using entry_date.How do I do this? Thanks,Gary |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2007-11-26 : 12:35:12
|
| look up min() in BOL (Books online). |
 |
|
|
gblack
Starting Member
2 Posts |
Posted - 2007-11-26 : 13:10:58
|
| I tried this, but it only gives me one record. I am assuming that it is the minimum value for all Ticket_Date(s).SELECT Ticket_ID, Min(Ticket_Date) as Min_Date FROM Temp_TicketsGroup by Ticket_IDIn theory the above query should have listed one ticket_id for each set of ticket_id(s) which were the same and posted the record with the lowest Ticket_Date. I don't understand why it didn't do this and only listed one ticket. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-26 : 19:50:42
|
quote: Originally posted by gblack I tried this, but it only gives me one record. I am assuming that it is the minimum value for all Ticket_Date(s).SELECT Ticket_ID, Min(Ticket_Date) as Min_Date FROM Temp_TicketsGroup by Ticket_IDIn theory the above query should have listed one ticket_id for each set of ticket_id(s) which were the same and posted the record with the lowest Ticket_Date. I don't understand why it didn't do this and only listed one ticket.
Do you have more than one value of Ticket_ID in the Temp_Tickets table ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|