SUM(
CASE
WHEN p2.lbttosubj='O'
THEN p1.judgeidt--为数字类型
ELSE 0
END) AS judgeidttriloss
FROM ods.t_idtlbts p1,
ods.t_lbt p2
WHERE p1.lbtcode=p2.lbtcode and p1.isclaimLbt='N'
gROUP BY claimno
SUM(
CASE
WHEN p2.lbttosubj='O'
THEN bigint( p1.judgeidt)
ELSE 0
END) AS judgeidttriloss
FROM ods.t_idtlbts p1,
ods.t_lbt p2
WHERE p1.lbtcode=p2.lbtcode and p1.isclaimLbt='N'
gROUP BY claimno
--这样虽然不会报溢错误,但是我的数据就不精确了,因为p1.judgeidt)后面有小数,
(3)
SELECT claimno,
SUM(
CASE
WHEN p2.lbttosubj='O'
THEN trunc(p1.judgeidt,3) ---trunc(x[,y])返回x截为y位小数的结果值
ELSE 0
END) AS judgeidttriloss
FROM ods.t_idtlbts p1,
ods.t_lbt p2
WHERE p1.lbtcode=p2.lbtcode and p1.isclaimLbt='N'
gROUP BY claimno