Skip to content
Advertisement

PostgreSQL – why is this statement causing a syntax error?

SELECT
        (SELECT COUNT(*) FROM table1) AS count1 WHERE date='2019-06-12',
        (SELECT COUNT(*) FROM table2) AS count2 WHERE date='2019-06-12'

why is this statement causing a syntax error at or near “,”?

Advertisement

Answer

need to add where clause inside subquery

SELECT
       (SELECT COUNT(*) FROM table1 WHERE date='2019-06-12') AS count1 ,
       (SELECT COUNT(*) FROM table2 WHERE date='2019-06-12') AS count2 
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement