You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I assume this has to do with how statement splitting is implemented.
The SQL formatter I use likes to put blank lines between CTEs.
WITH users_cte AS (
SELECT
id,
email
FROM account
WHERE tier ='Pro'
),
active_sessions_cte AS (
SELECT
accountid,
count(*) AS session_count
FROM session
WHERE expiresat >current_timestampGROUP BY accountid
)
SELECTu.id,
u.email,
coalesce(s.session_count, 0) AS active_sessions
FROM users_cte AS u
LEFT JOIN active_sessions_cte AS s ONu.id=s.accountidORDER BY active_sessions DESC;
Output
path/to/example.sql:7:3 syntax ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Expected Ident
5 │ FROM account
6 │ WHERE tier = 'Pro'
> 7 │ ),
│
> 8 │
> 9 │ active_sessions_cte AS (
│
10 │ SELECT
11 │ accountid,
path/to/example.sql:7:3 syntax ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Expected As
5 │ FROM account
6 │ WHERE tier = 'Pro'
> 7 │ ),
│
> 8 │
> 9 │ active_sessions_cte AS (
│
10 │ SELECT
11 │ accountid,
path/to/example.sql:7:3 syntax ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Expected Ascii40
5 │ FROM account
6 │ WHERE tier = 'Pro'
> 7 │ ),
│
> 8 │
> 9 │ active_sessions_cte AS (
│
10 │ SELECT
11 │ accountid,
Checked 1 file in 37ms. No fixes applied.
Found 3 errors.
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× Some errors were emitted while running checks.
The text was updated successfully, but these errors were encountered:
I assume this has to do with how statement splitting is implemented.
The SQL formatter I use likes to put blank lines between CTEs.
Output
The text was updated successfully, but these errors were encountered: