select sum(cast(TranAmt as numeric(19,2))) TranAmt1 from T_Phone_Journal where ( Samid Like '%" & strFind & "%') and RetCode='0000' and TransType=123
select sum(cast(TranAmt as numeric(19,2))) TranAmt2 from T_Phone_Journal where ( Samid Like '%" & strFind & "%') and RetCode='0000' and TransType=223
这是两条查询怎样让他们和在一起
在不同条件下取不同的金额
select sum(cast(TranAmt as numeric(19,2))) TranAmt2 from T_Phone_Journal where ( Samid Like '%" & strFind & "%') and RetCode='0000' and TransType=223
这是两条查询怎样让他们和在一起
在不同条件下取不同的金额
case when RetCode='0000' and TransType=223 then sum(cast(TranAmt as numeric(19,2))) TranAmt2 end
from T_Phone_Journal where ( Samid Like '%" & strFind & "%') and RetCode='0000' and TransType=123
select case when RetCode='0000' and TransType=123 then
sum(cast(TranAmt as numeric(19,2))) TranAmt1,
case when RetCode='0000' and TransType=223 then
sum(cast(TranAmt as numeric(19,2))) TranAmt2 end
from T_Phone_Journal
sum(cast(TranAmt as numeric(19,2)))
,(case TransType when 123 then TranAmt1 when 223 then TranAmt2 end)
from T_Phone_Journal
where ( Samid Like '%" & strFind & "%')
and RetCode='0000'
(
select sum(cast(TranAmt as numeric(19,2))) TranAmt from T_Phone_Journal where ( Samid Like '%" & strFind & "%') and RetCode='0000' and TransType=123
union all
select sum(cast(TranAmt as numeric(19,2))) TranAmt from T_Phone_Journal where ( Samid Like '%" & strFind & "%') and RetCode='0000' and TransType=223
) t