Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I would like to remove the duplicate time and select only single rowLoginid time refid count26692 2004-04-07 21:12:18.233 3268 126692 2004-04-07 21:22:36.107 3268 144657 2004-04-13 14:45:16.560 3909 145138 2004-04-13 19:47:31.840 18869 1
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts
Posted - 2004-07-14 : 21:30:29
What is the business rule that determines which refid to display ?And what table is refid in ?You could add a subquery in the where clause like :WHERE refid = (SELECT min(refid) FROM table WHERE loginid = login.loginid and time = login.time)You'll have to customise that to suit, you haven't given enough info for me to do it exactly.Damian
Kristen
Test
22859 Posts
Posted - 2004-07-14 : 22:04:24
Could it be just a
SELECT Loginid, time, MIN(refid), count(*)from loginjoin login_h on login.login_id = login_h.login_id returnGROUP BY Loginid, time