Hi,
I want to make a SQL question that selects the row with the highest incrementid. The current sql query is made with a subquery. I don't want any subquerys regarding to performance.
Data consists by. The last column value is increment id.
RID OwnerRID CreatedBy CreatedDate ValidFromDate ValidToDate IncrementId
BB7B6D1A-20FA-E811-A92B-1C4D701E2313 25C71200-60AE-443D-A0B7-424A7EDEA24C JMeterTest 2018-12-07 14:01:00 2017-12-01 12:00:00 2017-12-01 12:15:00 1118
689CB599-7DFC-E811-A92B-1C4D701E2313 57627ABA-51F3-4692-B3DE-0BBDD196C828 JMeterTest 2018-12-10 14:15:00 2017-12-01 12:00:00 2017-12-01 12:15:00 1241
699CB599-7DFC-E811-A92B-1C4D701E2313 57627ABA-51F3-4692-B3DE-0BBDD196C828 JMeterTest 2018-12-10 14:15:00 2017-12-01 12:00:00 2017-12-01 12:15:00 1242
I have tried to make an SQL query but it does not work:
SELECT PN.RID
FROM part.Participation PN
LEFT JOIN part.Participation PN1 ON (PN.OwnerRID = PN1.Ownerrid AND PN1.IncrementId > PN.IncrementId)
INNER JOIN @PARTICIPATION PARAM_PN ON (PARAM_PN.RID = PN.OwnerRID);
Can someone give me a tip!
sudipta sanyalRank #1,945 · 753 reputationPosted Dec 11, 2018, 10:09 PM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Dec 10, 2018, 2:43 AM EST
Hakan AxheimRank #8,316 · 224 reputationPosted Dec 10, 2018, 2:47 AM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Dec 10, 2018, 3:06 AM EST
Sourav MukherjeeRank #850 · 2.6K reputationPosted Dec 10, 2018, 4:01 AM EST
Vignesh ManiRank #98 · 22.1K reputationPosted Dec 10, 2018, 4:26 AM EST
Hakan AxheimRank #8,316 · 224 reputationPosted Dec 10, 2018, 8:16 PM EST
Is NOT EXISTS good for performance?
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts