Skip to content
Advertisement

Tag: group-by

SELECT id HAVING maximum count of id

Have a products table with item_id and color_id. I’m trying to get the color_id with the most non-null instances. This fails: with This Returns I am looking for color_id 3, which has the most instances. Is there a quick and easy way of getting what I want without 2 queries? Answer This will give you the color_id and the count

JOIN two SELECT statement results

Is it possible to join the results of 2 sql SELECT statements in one statement? I have a database of tasks where each record is a separate task, with deadlines (and a PALT, which is just an INT of days from start to deadline. Age is also an INT number of days.) I want to have a table which has

Return all duplicate rows

I’ve written this code to find duplicates and it works fine: The problem is, it’s returning just one of the duplicate rows. Is it possible to return all the duplicate rows? I’m guessing it may have something to do with the ‘GROUP BY’ but I’m not sure how to change it. I don’t want to delete the values, just return

Advertisement