带别名的派生表

时间:2014-07-16 17:21:25

标签: sql teradata

select fullcount.c1, internalcustomers.c2, anonymousTransid.c3, companyNo.c4
from (
select count(*) as c1 
from Customer
WHERE CustomerID not in (select CustomerID from Address)
) as fullcount
join
(
select count(*)  as c2
from Customer
where trim(firstname) not between '0' and '9999999999999999'
and CustomerID not in (select CustomerID from Address)
) as internalcustomers
on  fullcount.c1 = c2.customerid

(
select count(*) as c3
from Customer
where trim(firstname) between '0' and '9999999999999999'
and CustomerID not in (select CustomerID from Address) 
)as anonymousTransid
join
(
select count(*) as c4 
from Customer
where trim(firstname) not between '0' and '9999999999999999'
and iscompany like '%n%' 
and CustomerID not in (select CustomerID from Address) 
)as companyNo
on anonymousTransid.c3=companyNo.c4

为我的计算列和我的派生表分配了别名..在另一个论坛上看到了这个但我无法运行我的查询

0 个答案:

没有答案