第一列是-主键-地区-销售人员-销售总额,
请问查询-每个地区销售金额最少的人是谁
select * from (
select rank() over(partition by region order by total) as rid
,orderid,region,sales,total
from salesorder ) t
where t.rid = 1
select * from salesorder
where sales="张%" and total="5000000"
查询符合姓张 和总计达到5000000 的条件
select min(sales) from salesorder group by region
SELECT a.* FROM (SELECT id, region, sales, SUM(total) AS total FROM salesorder GROUP BY sales ORDER BY total) a GROUP BY a.region
select s.* from
salesorder s,
(
select min(total) t,orderid from salesorder group by region
) a
where s.orderid=a.orderid and a.t=s.total
select region,min( total) from salesorder
group by region
select * from salesorder where total = (select max(total) from salesorder)
select * // * 表示要查询的列名之类的, *可表示查询来自“XX”中的所有列的信息
from XX // XX表示要查询的“表名”
where XXX // XXX 表示一些条件语句。当然这个条件语句中,也可以用来嵌套另一个表中的相关信息。
数据库去年学的,现在的一些知识点记得不大清楚。哈哈
select * from (
select rank() over(partition by region order by total) as Rid
,orderid,region,sales,total
from salesorder ) t
where t.Rid = 1
select * from salesorder b, ( select min(total) as minprice,goodregion s_status from salesorder group by region ) a where a.region=b.region and a.minprice=b.goodregion
select * from salesorder m where m.total
in (SELECT min(total) total from salesorder group by region);
select id,region,sales,min(total) as total from salesorder
GROUP BY region ORDER BY total;
select s.* from
salesorder s,
(
select min(total) t,region from salesorder group by region
) a
where s.region=a.region and a.t=s.total