I received this answer from someone else Q before, but I would like to get an explanation of this so that I fully understand the problem.
I have a table with a column that contains the value of either "private" or "company". The thing is, I want to check how many "private" and "company" values ββare in my records, so that I can display them with the search results later. So if there are 4 company ads and 1 private ad, this is the result:
Company = 4
Private = 1
All ads = 5
And here is the code I received from someone about how to do this, in other words, this is what I would like to explain:
SELECT
IFNULL( field , 'All ads' ) AS 'Type',
COUNT( * )
FROM
`table`
GROUP BY
field
WITH ROLLUP
thank
user188962
source
share