create or replace view web_今日签约1 as
select b.所属区,
case
when b.buse='住宅' then count(b.id) as 今日签约住宅
from web_bargain_liut b
where to_char(b.preselltime,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd') and b.buse = '住宅' and b.type =1 and (b.stat =1 or b.stat=2)
group by b.所属区
在count这个地方错误 我想统计住宅的今日数量 不知道怎么来改?? 谢谢
select b.所属区,
case
when b.buse='住宅' then count(b.id) as 今日签约住宅
from web_bargain_liut b
where to_char(b.preselltime,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd') and b.buse = '住宅' and b.type =1 and (b.stat =1 or b.stat=2)
group by b.所属区
在count这个地方错误 我想统计住宅的今日数量 不知道怎么来改?? 谢谢
count(case when b.buse='住宅' then b.id else b.id) as 今日签约住宅 为什么?你应该很明白!!!!将b.buse='住宅'放到where子句中,这样就OK啦!因为你只想得到令日签约的数量,其他你都不需要!如果是两者都要,改用我上面写的就可以了