请教高手~~,简单的SQL语句

byimbba 2006-06-16 05:10:04
我要查询 数据库 中 ,价格最贵的那本书的名称.
select book.name ,max(book.price) from bookk group by book.name
得出得数据不是我想要得,这该怎么写啊??
...全文
129 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
CNNO01 2006-06-16
  • 打赏
  • 举报
回复
select name,price from book where price in(select max(price) from book)
godfather_wang 2006-06-16
  • 打赏
  • 举报
回复
select name,maxprice from bookk a,(select max(book.price) as maxprice from bookk ) b
where a.price=b.maxprice
billpu 2006-06-16
  • 打赏
  • 举报
回复
select top 1 name from book order by price desc
xeqtr1982 2006-06-16
  • 打赏
  • 举报
回复
select name from book a where not exists(select 1 from book where name=a.name and price>a.price)

--少打了个and
xeqtr1982 2006-06-16
  • 打赏
  • 举报
回复
你这样应该可以阿

select name from book a where not exists(select 1 from book where name=a.name price>a.price)
xq02 2006-06-16
  • 打赏
  • 举报
回复
select a.name,a.price from bookk a where not exists(select * from bookk where price>a.price)

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧