GeekInterview.com
Series: Subject: Topic:
Question: 10 of 214

Count Records

I have following table as books101

BOOK_NO BOOK_NAME AUTHOR_NAME COST CATEGORY
1234 C Dennis 450 System
1235 Oracle Loni 550 Database
1236 Sql Loni 250 Database
1237 Pl/Sql Scott 750 Database


Now I want to List all the authors and book name that has more then 1 book written by them.

pls help
Asked by: abhi.mys1111 | Member Since Jun-2012 | Asked on: Jun 15th, 2012

View all questions by abhi.mys1111

Showing Answers 1 - 3 of 3 Answers
kannandevan

Answered On : Jun 15th, 2012

View all answers by kannandevan

by grouping book and author

Code
  1. SELECT book_name,author_name,count(*) FROM books
  2. GROUP BY book_name,author_name
  3. HAVING count(*)>1

  
Login to rate this answer.
kannandevan

Answered On : Jun 15th, 2012

View all answers by kannandevan

select book_name,author_name,count(*) from books
group by book_name,author_name
having count(*)>1

  
Login to rate this answer.
Avinash

Answered On : Jun 24th, 2012

select AUTHOR_NAME,BOOK_NAME from books101
where AUTHOR_NAME in
(select author_name from books101 group by author_name having count(*)>1);

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.