Skip to content

Exclude based on sub-table’s value

Consider the table Audit, and AuditStatus. Where auditId in AuditStatus is a foreign key, mapping the pk of table Audit. table Audit id | auditName | 1 | test | 2 | fooTest | 3 …

Select the Max row number for an account

I need to only pull the max row number for an account. I know it’s a grouping issue. Current data: ACCOUNT_UID ID NAME ACADEMIC_PERIOD CAT_BY_DATE CAT_DATE MAX_ROW abc abc Popeye 202190 CPT 9/15/2021 1 abc abc Popeye 202190 CSH 10/4/2021 2 I only need the second row. Current query: Answer You can try th…

SQL statement to count occurrences in list

i would like to run an SQL query to calculate the number of passes and fails in a list. I’ve created a scenario with students and grades to better explain my problem. I have 2 tables one being the student table studentid firstname lastname 1 Sponge Bob 2 Patrick Star and another table being the grades s…

Add join and search in columns for any string

I have these Postgres tables: I use this SQL query: How I extend this SQL query to search also in table employees by employee id and filter the result by any character found in table columns first_name and last_name? Answer You can join the new table using employee_id: