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.
hi, by executing this qry i will get below result ,in that TId is duplicates that is from that i want recent record with same result.i want last one if TId comes duplicate record. any one ans pl select sa.GrandTotal, sa.TId, sa.Id,sa.Date, pr.PName,pr.PCode from Sales saLeft Outer Join Product pr on sa.Pid = pr.Id where sa.GrandTotal is not nullGrandTotal TId Id Date PName PCode200 1 2 2014-01-30 18:46:55.000 RK 100560 2 5 2014-01-30 18:47:49.000 RK 100420 2 6 2014-01-30 19:55:11.000 RK 100Radhakrshnan
waterduck
Aged Yak Warrior
982 Posts
Posted - 2014-02-12 : 04:04:51
few way to do this, this is one of it
select sa.GrandTotal, sa.TId, sa.Id,sa.Date, pr.PName,pr.PCode from Sales saLeft Outer Join Product pr on sa.Pid = pr.Id where sa.GrandTotal is not nulland sa.Date = (select MAX(date) from Sales sb where sa.pid = sb.pid)