我有这张桌子
ProductId ProductName Category Price
1 Tiger Beer $12.00
2 ABC Beer $13.99
3 Anchor Beer $9.00
4 Apolo Wine $10.88
5 Randonal Wine $18.90
6 Wisky Wine $30.19
7 Coca Beverage $2.00
8 Sting Beverage $5.00
9 Spy Beverage $4.00
10 Angkor Beer $12.88
如何选择除最高价格以外的所有结果 最高价格为$ 30.19
谢谢!
答案 0 :(得分:2)
您可以在下面尝试
select * from tablename where price not in
(select max(price) from tablename)
答案 1 :(得分:2)
您可以这样查询最高价格:
select max(Price) from Products; -- Assuming 'Products' is your table name
然后您可以将该查询嵌入另一个查询中,以获取价格低于该价格的所有产品:
select
*
from
Products
where
Price < (select max(Price) from Products)
答案 2 :(得分:1)
您可以使用运算符并使用max函数来实现。
Select * from Prices where Price < (select max(Price) from Prices)
答案 3 :(得分:0)
一个选择是使用max
作为Windows分析函数:
select q.ProductId, q.ProductName, q.Category, q.Price
from
(
select t.*,
max(t.price) over (order by t.price desc) max_price
from t
) q
where q.price < max_price;
答案 4 :(得分:0)
select * from tablename where price not in
(select max(price) from tablename)