Skip to content

Tag: sql

SQL many to many

I have fivetables here: User +——–+———-+ | stu_id | batch-id | +——–+———-+ | 1 | 1 | | 2 | 1 | | 3 | 1 | +——–+———-+ subject_id +-…

Unterminated dollar quote

How to use IF statement in the PostgreSql (11 version)? I tried just raw IF usage but got problem (syntax error at or near “IF”). To resolve this problem people propose to use ‘do &&’ but it does not work as well (Unterminated dollar quote started at position 3 in SQL DO $$ BEGIN IF &#8230…

Count sum of two columns

I am trying to count the sum of 2 columns from a subset of results, so far I have put this together SELECT COUNT(*) FROM table_name WHERE column_1 + column_2 >= 3 IN (SELECT id …