Querying a table with no Key field

We have a table that is storing Sales History for Part numbers by Branch. Part #s can exist in one, or many Branches. Columns include the Current month, and 3 previous months. I need to write a SELECT query that will list all the Part #s that have zero Sales History in ALL Branches. Using… Read More Querying a table with no Key field

SQL – After group by filtering down to rows where column value = certain string

Not sure why this isn’t working. When I run the query without HAVING segment ilike ‘Enterprise’ I get results (see screenshot) but when I add it back in the query returns nothing despite clearly containing instances where segment = ‘Enterprise’. I can’t find any instances online where having is used to filter for strings so… Read More SQL – After group by filtering down to rows where column value = certain string

MySQL | Trouble Combining JOIN, GROUP BY, and HAVING SUM

I’m trying to aggregate data from two tables and having trouble displaying it correctly. I searched for an answer to my question on stackoverflow, MySQL documentation, and several tutorials with no luck. Anyway, here’s what I got. SELECT works_with.client_id AS ‘Client ID’, client.client_name AS ‘Client Name’, works_with.total_sales AS ‘Total Sales’ FROM works_with JOIN client ON… Read More MySQL | Trouble Combining JOIN, GROUP BY, and HAVING SUM

Is there possible to remove 1 records or max(id) from GROUP_CONCAT MYSQL

I have to remove/skip the 1st records or max id in group_concat MYSQL. Here is query select email, group_concat(id order by id desc) as id from api_admin.external_user group by email having count(1) > 1; >Solution : Your GROUP_CONCAT() returns a string which is a comma separated list of at least 2 ids (because of the… Read More Is there possible to remove 1 records or max(id) from GROUP_CONCAT MYSQL