各位大牛,请教一下。这条sql语句用linq怎么写啊 10C

select a.MouthsId as 月份,
SUM(case when [years]='2017' and g.Code='19191919' and g.GprsType=1 then b.WaterConsumption else 0 end),
SUM(case when [years]='2017' and g.Code='19191919' and g.GprsType=2 then b.WaterConsumption else 0 end)
from Mouth as a left JOIN [MeterRecordHistory]
as b on a.MouthsId=b.mouths
left JoIn Meter as m on m.id=b.MeterId
left JoIn Hub as h on h.Id=m.HubId
left JoIn Gprs as g on g.Id=h.GprsId
group by a.MouthsId order by a.MouthsId

1个回答

https://www.cnblogs.com/xinjian/archive/2010/11/17/1879959.html
case when [years]='2017' and g.Code='19191919' and g.GprsType=1 then b.WaterConsumption else 0 end
用三目运算就可以了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问