从titles表中显示出最高价和最低价的书名的价格(无限制条数,但价格只有两种价格,且显示出的只有两种价格的书)
我用:
select title, price from titles having price=max(price) or price=min(price) 查询报错.
请教各位大侠哈!
我用:
select title, price from titles having price=max(price) or price=min(price) 查询报错.
请教各位大侠哈!
Where price = (Select max(price) From titles)
Or price = (Select min(price) From titles)
where not exists(Select * from titles where price>a.price)
Union all
Select '最低价: ' as kind,title, price from titles as a
where not exists(Select * from titles where price<a.price)
select title, price from titles
Where price = (Select max(price) From titles)
Union All
select title, price from titles
Where price = (Select min(price) From titles)
select title, price from titles ta
where not exists (select 1 from titles where price>ta.price)
union all
select title, price from titles ta
where not exists (select 1 from titles where price<ta.price)