netezza表的IN子句是否有限制?

时间:2014-02-09 18:13:33

标签: sql netezza

create table accounts as
select account_name, count(company) from tmp_table
where account_name in (select account_name from test_accounts)
group by account_name;

select * from accounts;

此查询仅获取12条记录,而在我的情况下它应该是50条记录,因为test_accounts中有50条记录。

我尝试了很多东西。

create table accounts as
select account_name, count(company) from tmp_table
where account_name in (list the name of all accounts in test_accounts)
group by account_name;

create table accounts as
select account_name, count(company) from tmp_table
where (added every account name in test_accounts with an OR clause)
group by account_name;

在所有情况下,我只有12条记录。

如果我查询tmp_table,他们就在那里。

我错过了什么?

感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

我会尝试以下方法。根据account_name的数据类型,我还会考虑使用upperlower将所有数据转换为相同的案例,如果不是案例问题那么我会怀疑你有空格或其他需要修剪的字符。

select ta.account_name
,nvl(tt.account_name,'No Match Found') as tmp_tbl_acct_nm
, count(tt.company) from (select account_name from test_accounts) ta  left outer join
 tmp_table tt
on trim(both from lower(ta.account_name))=trim(both from lower(tt.test_accounts))
group by ta.account_name,nvl(tt.account_name,'No Match Found');