Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to check multiple condition while using group by statements in sql

BOOK_ADOPTION (course:int, sem:int, book_isbn:int)

TEXT (book_isbn:int, booktitle: varchar(50), publisher: varchar(50), author: varchar(50))

List the books which are adopted by the course as well as enrolled by the student.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am trying this:

select course 
from text 
natural join book_adoption 
group by course 
having count(book_isbn)>1 
  and publisher = 'perason';

and getting an error:

Unknown column ‘publisher’ in ‘having clause’

but the column publisher is there and even the spelling is correct.
Can someone help me out with this one?

>Solution :

HAVING clause is for using with aggregating functions (like count) but in the case of publisher you have to simply use the WHERE condition.

select course
from text natural join book_adoption 
where publisher = 'perason'
group by course 
having count(book_isbn)>1;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading