我想 运行 嵌套查询,首先执行左连接,然后提取数据,其中 Volume >= 2 和最近 3 个月的日期

I want to run a nested query, where first perform a left join and then pull out data where Volume >= 2 and Date for last 3 months

我正在尝试 运行 一个嵌套查询,我在其中执行左连接,然后形成左连接数据 我正在提取卷 > 2 和日期(如果是过去 3 个月)的记录。我遇到错误,想了解如何更正查询并使其正常工作以及我做错了什么。将不胜感激。

Select 
(topic_desc as Category, acct_nbr, count(acct_nbr) as Volume, received_dt 
from temp.MS_CallCenter_Make_it_Right
LEFT JOIN bob_mir_accounts
ON temp.MS_CallCenter_Make_it_Right.acct_nbr = bob_mir_accounts.Account
Where bob_mir_accounts.Account is Null;), topic_desc as Category, acct_nbr, count(acct_nbr) as Volume, received_dt
FROM temp.MS_CallCenter_Make_it_Right
where Volume >= 2 AND received_dt >= date_sub(current_date, 90)
group by topic, acct_nbr
order by volume asc;

Error in SQL statement: ParseException: extraneous input '{' expecting {')', ','}(line 3, pos 0)

== SQL ==

Select 
(topic_desc as Category, acct_nbr, temp.MS_CallCenter_Make_it_Right.count(acct_nbr) as Volume, received_dt 
{from temp.MS_CallCenter_Make_it_Right
^^^
LEFT JOIN bob_mir_accounts
ON temp.MS_CallCenter_Make_it_Right.acct_nbr = bob_mir_accounts.Account
Where bob_mir_accounts.Account is Null

这不是答案,很难说出您实际想要做什么。但只是为了让您了解正确的语法。

Select Category,
       acct_nbr,
       volume,
       received_dt
  FROM (SELECT topic_desc as Category,  
               acct_nbr, 
               count(acct_nbr) as Volume, 
               received_dt 
          from temp.MS_CallCenter_Make_it_Right
          LEFT 
          JOIN bob_mir_accounts
            ON temp.MS_CallCenter_Make_it_Right.acct_nbr = bob_mir_accounts.Account
         WHERE bob_mir_accounts.Account is Null
         GROUP
            BY topic_desc,
               acct_nbr,
               received_dt
       ) TMP
 WHERE volume >= 2
   AND received_dt >= date_sub(current_date, 90);