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 |
|
Nroblex
Starting Member
17 Posts |
Posted - 2010-03-18 : 09:59:23
|
| Hi Gurus.Perhaps you can help me out with this?I have a simple table like this:[CreatedTimeStamp](dateTime) [StatusValue] varchar(20)2010-03-19 19:20:23.949 'Incomming'2010-03-19 19:20:24.843 'Sending'2010-03-19 19:20:25.521 'Recieved'2010-03-19 19:20:25.526 'Recieved'As you can se the third and fourth line are identical in the StatusValue columnI Want to use an sql-query that returns different records on both columns. How would you construct that query?The result must be like this:[CreatedTimeStamp](dateTime) [StatusValue] varchar(20)2010-03-19 19:20:23.949 'Incomming'2010-03-19 19:20:24.843 'Sending'2010-03-19 19:20:25.521 'Recieved'Many Thanks in advance//Nroblex |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-03-18 : 10:28:09
|
| Try it and let me know if it helps you.Declare @Temp Table(CreatedTimeStamp datetime, StatusValue Varchar(20))Insert into @TempSelect '2010-03-19 19:20:23.949', 'Incomming'unionSelect '2010-03-19 19:20:24.843', 'Sending'UnionSelect '2010-03-19 19:20:25.521', 'Recieved'UnionSelect '2010-03-19 19:20:25.526', 'Recieved'select * from @TempSelect min(CreatedTimeStamp), StatusValuefrom @Tempgroup by StatusValueRegards,Bohra |
 |
|
|
Nroblex
Starting Member
17 Posts |
Posted - 2010-03-18 : 11:19:27
|
| I did solve this using a unique NONCLUSTERED INDEX with Ignore_dup_keythanks anyway |
 |
|
|
|
|
|