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
Tag: having
filtering using having by clause result in unknown column in having clause
i have a table with these columns: order_date (in yyyy-mm-dd format), order_status, product_sub_category, sales. the data consists of transactions from 2009 onwards. what i want to do is to find the total sales of each product categories in between the year 2011 and 2012. to do that, i use these query: the problem is that sql tells me unknown column
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
using FETCH clause is not allowed in mysql .what alternative to be used instead
hi I have 2 tables want to use aggregation and having cluse. can u plz check my query? does not work Answer The nested aggregation MAX(SUM(registration.RegFeeAmntPaid)) is the problem: Nested aggregations are not allowed in SQL: After the first aggregation, there is only one value. Thus, aggregating again does not make sense. (In Oracle, under SELECT of a GROUP BY
MYSQL Select different records from same table
I am working on small school database and I need some help with selecting students that are only booked on different days in week 1 and week 2. My table structure is like below: I would like to get all the children that meet the following criteria: ONLY booked in week two (This is ChildId 2 and I can get
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
“IS NOT NULL” not producing the required results in mySQL
I am trying to build a report based of my table. Here is my table: Following is the SQL query to get desired results. I am looking to exclude entries which have all null values and following is my syntax but it is not working and produces the same results. Kindly help here or share a post that can help.
Select values for a column only if there are no rows with that value that satisfy a condition
I have a table that stores logs of http fetches, let’s say we have two columns: fetch_url and success. A few example rows: success fetch_url TRUE A FALSE A FALSE B FALSE B FALSE …
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