我正在运行此查询
select
case when "Payment Collection Fee" = 0 then
round(("Comm (Incl. S.Tax)" - ((("Marketing Fee" *16)/100)+"Marketing Fee"+0+"Courier Fee")),2)
when "Web Sale Price" < 0 then round(("Comm (Incl. S.Tax)" - ((("Marketing Fee" *16)/100)+"Marketing Fee"-20+"Courier Fee")),2)
else
round(("Comm (Incl. S.Tax)" - ((("Marketing Fee" *16)/100)+"Marketing Fee"+20+"Courier Fee")),2)
end as diff
from
meta.sd_payment_error
现在我想添加条件
where diff > 10
但是它给出错误diff列不存在
我如何为上述查询添加条件?
答案 0 :(得分:0)
使用派生表:
select *
from
(
select
case when "Payment Collection Fee" = 0 then
round(("Comm (Incl. S.Tax)" - ((("Marketing Fee" *16)/100)+"Marketing Fee"+0+"Courier Fee")),2)
when "Web Sale Price" < 0 then round(("Comm (Incl. S.Tax)" - ((("Marketing Fee" *16)/100)+"Marketing Fee"-20+"Courier Fee")),2)
else
round(("Comm (Incl. S.Tax)" - ((("Marketing Fee" *16)/100)+"Marketing Fee"+20+"Courier Fee")),2)
end as diff
from
meta.sd_payment_error
) as dt
where dt.diff > 10
答案 1 :(得分:0)
您可以使用Common Table Expression:
#include <stdio.h>
void main()
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF )
if (c == '\n')
++nl;
printf("%d \n", nl);
return 0;
}