In my last blog, I discussed the Use of Case() in MySQL and after publishing that post after a few days as usual while solving this specific Problem 1693. Daily Leads and Partners at LeetCode. I have used Group By several times but never used it in this particular way – “GROUP BY 1, 2, 3”. After going through several blogs and forums I have found out that its a shortcut to denoting the column in a series, such as;

Here 1 will be referring 1=> data_id, 2=> make_name and so on

Table Details

For the solution to this problem, I have used the following query;

SELECT date_id, make_name, COUNT(DISTINCT lead_id) AS unique_leads, COUNT(DISTINCT partner_id) AS unique_partners
FROM DailySales
GROUP BY 1, 2;

Happy learning 💻💻

References