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.
I hope the query is clear and would be thankful if someone can solve my problem.
bitsmed
Aged Yak Warrior
545 Posts
Posted - 2015-03-14 : 15:37:48
[code]SELECT TOP(1) *FROM (SELECT count(*) AS books_lent, reader_id FROM borrow GROUP BY reader_id) AS nr_lentORDER BY books_lent DESC[/code]
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2015-03-15 : 02:24:34
[code]SELECT TOP(1) WITH TIES COUNT(*) AS Books_Lent, Reader_IDFROM dbo.BorrowGROUP BY Reader_IDORDER BY COUNT(*) DESC;[/code]Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA