We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,301 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

SQL Database language

Hello!
I am working on an SQL Database project and I am supposed to find the names of authors who have written 3 or more books. My code is below. The operator ">" is not valid and I have tried different variations of COUNT.

SELECT afirstname, alastname, btitle, COUNT(*) FROM Author, Book WHERE btitle > 2 GROUP BY alastname;

Author contains the names and Book contains the titles, pages, etc. There is also Author_Book containing aid and bid. Do I need to use a join? I still don't understand how I can specify 3+ books without using an operator. I am not asking for an answer, just some pointers if possible :).

Thank you!

2
Contributors
1
Reply
7 Hours
Discussion Span
2 Months Ago
Last Updated
8
Views
ANSAYLOR
Newbie Poster
1 post since Mar 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Have a look at using COUNT in HAVING.

Since btitle is a varchar column, you cannot compare it to an integer (it does not know you want to count).

pritaeas
Posting Prodigy
Moderator
9,310 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0585 seconds using 2.64MB