I’ve seen a few different versions of this question but having difficulty applying it to what I need…
MS SQL Server 2008 query:
SELECT Receipts.ReceiptID, Receipts.UserID, Receipts.UserCardID, FolderLink.ReceiptFolderLinkID
FROM dbo.tbl_ReceiptFolderLnk AS FolderLink
INNER JOIN dbo.tbl_Receipt AS Receipts ON FolderLink.ReceiptID = Receipts.ReceiptID
**
ReceiptID UserID UserCardID ReceiptFolderLinkID
-------------------- -------------------- -------------------- --------------------
1 1 3 2
2 1 3 3
3 1 3 10
4 1 4 11
5 1 4 13
6 2 5 14
3 1 3 15
4 1 4 16
**
Now I would like to get distinct values on ReceiptID. Using distinct will not work as distinct works on the entire row.
Help would be appreciated.
Thanks!
If you want all the results columns in your original query and want each ReceiptID to only show up one time, you’ll need to use GROUP BY.
Like: