EXCEL-SQL-group by计数

2017-07-20  本文已影响53人  叶知行

数据

数据

求属性1和属性2的差值(绝对值)小于300的数据且属性1的计数大于等于2。


select a.*,abs(a.属性1-a.属性2) as 差 
from  [Sheet1$a1:c] a,
(
select 属性1 from [Sheet1$a1:c] 
group by 属性1 having count(属性1)>1
) b 
where a.属性1=b.属性1 
and 
abs(a.属性1-a.属性2) <300

解释:

select 属性1 from [Sheet1$a1:c] 
group by 属性1 having count(属性1)>1
select a.*,abs(a.属性1-a.属性2) as 差 
from  [Sheet1$a1:c] a,
(
select 属性1 from [Sheet1$a1:c] 
group by 属性1 having count(属性1)>1    
) b 
where a.属性1=b.属性1                  --//条件1
and 
abs(a.属性1-a.属性2) <300              --//条件2
结果

示例文件下载
链接: http://pan.baidu.com/s/1c1FnUwg 密码: seq8

上一篇下一篇

猜你喜欢

热点阅读