consistency in sql server

Solutions on MaxInterview for consistency in sql server by the best coders in the world

showing results for - "consistency in sql server"
Juan Esteban
31 Nov 2020
1SELECT
2    TH.TransactionID,
3    TH.ProductID,
4    TH.ReferenceOrderID,
5    TH.ReferenceOrderLineID,
6    TH.TransactionDate,
7    TH.TransactionType,
8    TH.Quantity,
9    TH.ActualCost
10FROM Production.TransactionHistory AS TH
11WHERE TH.ReferenceOrderID =
12(
13    SELECT TOP (1) 
14        TH2.ReferenceOrderID
15    FROM Production.TransactionHistory AS TH2
16    WHERE TH2.TransactionType = N'P'
17    ORDER BY 
18        TH2.Quantity DESC,
19        TH2.ReferenceOrderID ASC
20);