Mr. Demagorgon
Mr. Demagorgon

Reputation: 9

How do I figure out this comma error in my SQL code?

I'm trying to run a set of subqueries but not sure what the issue is.

select 
    can, 
    sum(case when tax_year = 2018 then qty_req else 0 end) as TY18_esig,
    (select sum(case when tax_year = 2018 then qty_req else 0 end) as TY18_esig_unltd 
     from RPT_PCG_CART_CUR 
     where PRODUCT in ('eSignature Unlimited for ProSeries'),
    sum(case when tax_year = 2019 then qty_req else 0 end) as TY19_esig
from 
    RPT_PCG_CART_CUR
where 
    product IN ('eSignature Bank Jan 1 - Dec 31 2020', 'eSignature Unlimited for Lacerte')
    and cart_type = 'TRANSACTED'
group by 1
order by 1

The errors I get are:

[Code: 4856, SQL State: 42601] [Vertica]VJDBC ERROR: Syntax error at or near ","

or

[Code: 4818, SQL State: 0A000] [Vertica]VJDBC ERROR: Subqueries in the SELECT or ORDER BY are not supported if the subquery is not part of the GROUP BY

Upvotes: 0

Views: 253

Answers (1)

Dave Costa
Dave Costa

Reputation: 48121

As noted in the comment, you are missing a closing parenthesis / round bracket on your scalar subquery.

You should have two closing parens on this line before the comma:

where PRODUCT in ('eSignature Unlimited for ProSeries')),

Upvotes: 0

Related Questions