Skip to content
Advertisement

Tag: having

NULL MAX(col) value even though DB has a valid record

So I am trying to extract the maximum invoiceNo for current year and this is how I implemented it with PDO: However, $response keeps getting assigned to the else clause : . This is how my DB looks like: Hence I was expecting the $response to be 2022-2. I think there is something wrong with my SQL query and I

Filter table to leave out specific rows

I have the table and now I want to list every ProjectName where there is no specified Leader like this: Right now I only know how to filter all ProjectNames with Leaders, but not the way to filter them the other way! Any help is appreciated 🙂 Answer One way to do it is with aggregation and the condition in

Postgres – Select days with FAILURE status only

I have table with multiple result per days for particular project_name (SUCCESS, FAILURE, ABORTED, UNSTABLE). I would like to select only days where only FAILURE status occurs – nothing else. There are some days with multiple status (after FAILURE it can be solved and get status with different time and set to SUCCESS). How can I select only days with

GROUP BY with Key:Value filters for each group

Given a table with following schema: RecordId ProcessId Data 80830F00-379C-11EA-96B7-372060281AFC 1 4.2 80830F00-379C-11EA-96B7-372060281AFC 2 445588662211448 80830F00-379C-11EA-96B7-372060281AFC 7 1 791F6D30-379C-11EA-96B7-372060281AFC 1 3.3 791F6D30-379C-11EA-96B7-372060281AFC 2 999999999999999 791F6D30-379C-11EA-96B7-372060281AFC 7 2 So the RecordId represents some grouping key and each ProcessId has its Data. Now I have a filter which looks like this: So the key is ProcessId and value is Data. Question How

SQL – using ‘HAVING’ with ‘EXISTS’ without using ‘GROUP BY’

Using ‘HAVING’ without ‘GROUP BY’ is not allowed: Column ‘products.UnitPrice’ is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause. But when placing the same code under ‘EXISTS’ – no problems: Can you please explain why? Answer well the error is clear in first query UnitPrice is not part

Advertisement