论坛上看到有人说having子句不能单独使用,后面还有很多人赞同,我表示不能忍了..例子,举个最简单的select 1 from dual having count(1) = 1;
再说一个用途--书
create table book as
select 1 id,'小说A' name from dual union all
select 2 , '小说B' from dual union all
select 3 , '小说C' from dual;--用户读那本书
create table book_reader as
select 111 id, 1 bookid from dual union all
select 112 , 1 from dual union all
select 113 , 2 from dual ;--只有一个用户读的书
select *
  from book a
 where exists (select 1
          from book_reader b
         where a.id = b.bookid 
     having count(1) = 1);