case when如何用嵌套啊

mrfinger 2004-07-07 04:47:08
请举个例子好吗?
...全文
218 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
icedut 2004-07-07
  • 打赏
  • 举报
回复
select
sum(case when e.Authority = 'TT' then e.Quantity else 0 end) as et_tt,
sum(case when e.Authority = 'OH' and isnull(e.d_t, '2040-1-1') <> t.LastTT then e.Quantity else 0 end) as et_oh,
sum(case when e.Authority = 'HO' and isnull(e.d_t, '2040-1-1') <> t.LastTT then e.Quantity else 0 end) as et_ho,
sum(case when e.Authority = 'SS' and isnull(e.d_t, '2040-1-1') <> t.LastTT then e.Quantity else 0 end) as et_ss
from dbo.Table1 e with (nolock)

这样算嵌套么
wweight 2004-07-07
  • 打赏
  • 举报
回复
你在本版里搜一下"case"出来一堆,自己看看,我就不写了:)

34,870

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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