I have a sql server table named myTbl like this:
BookID PageID textID Date Remarks
1 4 9 21-12-2017 1
2 5 10 15-12-2017 1
3 6 11 13-12-2017 1
4 7 12 11-12-2017 1
2 5 10 22-12-2017 1
4 7 12 18-12-2017 1
I want to group the rows when BookID, PageID and textID have same values and show the result based on the most recent date ascending. For instance 4th & 6th row and 2nd & 5th row.
What I need is:
BookID PageID textID Date Remarks
1 4 9 21-12-2017 1
2 5 10 15-12-2017 1
2 5 10 22-12-2017 1
3 6 11 13-12-2017 1
4 7 12 11-12-2017 1
4 7 12 18-12-2017 1
How I want to write is:
SELECT *
FROM booksdb.dbo.books
GROUP BY BookID, PageID, textID Order by Date
I want all the columns in the table where BookID, PageID, textID are same and arranged by date.