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 |
|
nimesh
Starting Member
1 Post |
Posted - 2005-12-15 : 12:56:40
|
| hii have a table with multiple fields let me show you an exampleEvent_ID Occurrence_nbr seq_event_nmbr cause_fac>> 20001204X0000 1 1 cause>> 20001204X0000 1 2 cause>> 20001204X0000 1 3 factor>> 20001204X0001 1 1 cause>> 20001204X0001 1 2 causewhat i want is based on a event_id and occurrence_nbr i want the first seq_event_nmbr which is a cause, i just want the first seq_event_nmbr and not all.Is this possible?thanksnimesh |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-12-15 : 13:14:00
|
| Hi nimesh,Welcome to Sql Team!select Event_ID, Occurrence_nbr, min(seq_event_nmbr) as seq_event_nmbrfrom yourTablegroup by Event_ID, Occurrence_nbrwhere cause_fac = 'cause'rockmoose |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-16 : 00:49:46
|
| Small modification on rocky's codeWhere clause should be followed by Group by if anyselect Event_ID, Occurrence_nbr, min(seq_event_nmbr) as seq_event_nmbrfrom yourTablewhere cause_fac = 'cause'group by Event_ID, Occurrence_nbrMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|