在已经select的记录中如何再select

tufun 2005-07-19 05:15:59
我想在(select count(1) as cnt, sum(lab_amt) as total_amt from wty_mst groub by dt)记录集中 进行分组
类似
select sum(total_amt ) from
(select count(1) as cnt, sum(lab_amt) as total_amt from wty_mst groub by dt)
group by cnt
上句执行不了 不知道怎么写

...全文
91 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
denniswwh 2005-07-19
对,给子查询加别名
回复
zjcxc 2005-07-19
select sum(total_amt ) from
(select count(1) as cnt, sum(lab_amt) as total_amt from wty_mst groub by dt) a --加别名
group by cnt
回复
WangZWang 2005-07-19
select sum(total_amt ) from
(select count(1) as cnt, sum(lab_amt) as total_amt
from wty_mst groub by dt) as tbl --加入这个表别名
group by cnt
回复
phantomMan 2005-07-19
select sum(total_amt ) from
(select count(1) as cnt, sum(lab_amt) as total_amt from wty_mst group by dt)a
group by cnt

或者这样:
select sum(total_amt ) from
(select count(1) as cnt, sum(lab_amt) as total_amt from wty_mst group by dt) as a
group by cnt
回复
发帖
应用实例
创建于2007-09-28

2.7w+

社区成员

MS-SQL Server 应用实例
申请成为版主
帖子事件
创建了帖子
2005-07-19 05:15
社区公告
暂无公告