[Solved] Why does select error occur near this statement? [closed]


Your SQL CTE syntax is incorrect: you have a comma after the last CTE’s close-paren. The only time you need a comma there is if you have another CTE following it.

Try changing to

with unit as (
  select t.RefDate, ...
),                                        -- yes comma here, between CTEs
agg as (
  select u.RefDate, ...
)                                         -- no comma here, after the last CTE
select u.RefDate, u.Symbol, ...

9

solved Why does select error occur near this statement? [closed]