不知道偶描述清不清楚?
请各位朋友帮帮忙,急急急
6 个解决方案
#1
给出你的原始数据和你想要的结果
#2
假设表结构为:
id,code,name,type,time,flag............
我要查询flag为true的,且对type进行分组,然后取各组中的time值最小的
id,code,name,type,time,flag............
我要查询flag为true的,且对type进行分组,然后取各组中的time值最小的
#3
哪位兄台可以帮忙的??????
#4
如果没有其它条件的话下面语句应该可以
select * from tname,(select type min(time) time from tname where flag=true group by type) b
wehre tname.type = b.type and tname.flag=true and tname.time=b.time
select * from tname,(select type min(time) time from tname where flag=true group by type) b
wehre tname.type = b.type and tname.flag=true and tname.time=b.time
#5
我这里没有环境,可以试一下这个语句:
select id,code,name,type,time,flag from(
select id,code,name,type,time,flag,
rank() over(partition by type order by time) rn
from emp
where flag=true)
where rn=1;
select id,code,name,type,time,flag from(
select id,code,name,type,time,flag,
rank() over(partition by type order by time) rn
from emp
where flag=true)
where rn=1;
#6
表HOTEL.ORDERS: COMPANY ORDERNUMBER
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 2312
W3SCHOOLS 6798
SELECT COMPANY,SUM(ORDERNUMBER) FROM HOTEL.ORDERS
GROUP BY COMPANY
ORDER BY SUM(ORDERNUMBER)
得到结果: COMPANY ORDERNUMBER
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 9110
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 2312
W3SCHOOLS 6798
SELECT COMPANY,SUM(ORDERNUMBER) FROM HOTEL.ORDERS
GROUP BY COMPANY
ORDER BY SUM(ORDERNUMBER)
得到结果: COMPANY ORDERNUMBER
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 9110
#1
给出你的原始数据和你想要的结果
#2
假设表结构为:
id,code,name,type,time,flag............
我要查询flag为true的,且对type进行分组,然后取各组中的time值最小的
id,code,name,type,time,flag............
我要查询flag为true的,且对type进行分组,然后取各组中的time值最小的
#3
哪位兄台可以帮忙的??????
#4
如果没有其它条件的话下面语句应该可以
select * from tname,(select type min(time) time from tname where flag=true group by type) b
wehre tname.type = b.type and tname.flag=true and tname.time=b.time
select * from tname,(select type min(time) time from tname where flag=true group by type) b
wehre tname.type = b.type and tname.flag=true and tname.time=b.time
#5
我这里没有环境,可以试一下这个语句:
select id,code,name,type,time,flag from(
select id,code,name,type,time,flag,
rank() over(partition by type order by time) rn
from emp
where flag=true)
where rn=1;
select id,code,name,type,time,flag from(
select id,code,name,type,time,flag,
rank() over(partition by type order by time) rn
from emp
where flag=true)
where rn=1;
#6
表HOTEL.ORDERS: COMPANY ORDERNUMBER
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 2312
W3SCHOOLS 6798
SELECT COMPANY,SUM(ORDERNUMBER) FROM HOTEL.ORDERS
GROUP BY COMPANY
ORDER BY SUM(ORDERNUMBER)
得到结果: COMPANY ORDERNUMBER
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 9110
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 2312
W3SCHOOLS 6798
SELECT COMPANY,SUM(ORDERNUMBER) FROM HOTEL.ORDERS
GROUP BY COMPANY
ORDER BY SUM(ORDERNUMBER)
得到结果: COMPANY ORDERNUMBER
---------------------------
SEGA 3412
ABC SHOP 5678
W3SCHOOLS 9110