SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table books ( book_code int primary key, title varchar(64) ); insert into books values (1, 'book1'), (2, 'book2'); create table abonents ( bilet_number int primary key, name varchar(64) ); insert into abonents values (1, 'abonent1'), (2, 'abonent2'); create table lends ( book_code int, bilet_number int ); insert into lends values (1, 1), (2, 1), (2, 2), (1, 1); select * from abonents; select book_code, count(distinct bilet_number) lends from lends group by book_code having count(distinct bilet_number) = (select count(distinct bilet_number) from abonents)
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear