I have two table
- Book (BookID, BookName)
- Issue (BookID, IssueDate, Qty)
So, how can i find the maximum "issued book name" for a specified date.
I have two table
So, how can i find the maximum "issued book name" for a specified date.
select top 1 book.bookid, book.bookname from
(
select bookid, sum(qty) as s
from issue
where issuedate = @issuedate
group by bookid
) grp
inner join book
on book.bookid = grp.bookid
order by s
if by "maximum" you mean "the name of the book that has the largest quantity issued on a given date".
Something like this :
select BookName from Book
where BookId = (select BookId from Issue where IssueDate = @yourdate
AND Qty = (select MAX(Qty) from Issue))