views:

15

answers:

1

I want to show the BookTitle, Firstname along with a COUNT of Copies. When I run the query, it gives an error saying to group. But when I group it says not a expression to group. Can someone help me?

SELECT bk.BookTitle, au.FirstName, COUNT(bkc.BookCopyID), rb.ReservedDate 
FROM Book bk, Book_Author ba, BookCopy bkc, ReserveBook rb, Author au 
WHERE 
    bkc.BookID = bk.BookID 
    AND ba.BookID = bkc.BookID 
    AND ba.AuthorID = au.AuthorID 
    AND bkc.BookCopyID = rb.BookCopyID 
    AND rb.ReservedDate >= trunc(trunc(sysdate,'MON')-1,'MON') 
    AND rb.ReservedDate < trunc(sysdate,'MON') 
GROUP BY bkc.BookCopyID;
+1  A: 

remove your group by statement and add this,

Group by bk.BookTitle,au.FirstName,rb.ReservedDate

Assuming all your where conditions are right and you know what you are doing.

Srinivas Reddy Thatiparthy
yup.. thanks its working now
Nubkadiya