在已经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
上句执行不了 不知道怎么写

...全文
166 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
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

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧