前一阶段发了一个帖子,得到了大家的帮忙。
http://topic.csdn.net/u/20091216/11/3527ff34-0c2a-4121-9a53-8f74b0ed1dda.html
现在我想在这个基础上增加一列,列中显示当前设备被使用人数。比如计算机被三个人使用,就是3.
aid assetname person num
1 计算机 张三 3
1 计算机 赵六 3
1 计算机 李四 3
2 椅子 王五 2
2 椅子 赵六 2
3 桌子 冯七 1
http://topic.csdn.net/u/20091216/11/3527ff34-0c2a-4121-9a53-8f74b0ed1dda.html
现在我想在这个基础上增加一列,列中显示当前设备被使用人数。比如计算机被三个人使用,就是3.
aid assetname person num
1 计算机 张三 3
1 计算机 赵六 3
1 计算机 李四 3
2 椅子 王五 2
2 椅子 赵六 2
3 桌子 冯七 1
assetname,person ,
count(1)over(partition by assetname)num
from table1
order by 1
assetname,person ,
count(1)over(partition by assetname)num
from 表名
order by 1
(select count(1) from tb where aid = t.aid) num
from tb t