I make a query to the database: SELECT DISTINCT MODEL FROM advert WHERE COMPLETE = 1 The list of models from the ad table is displayed, without repetitions. And how in the same request to specify the output of the number of ads in which these models? Example:

Model1 = 232 ads

Model2 = 112 ads

Model3 = 31 listings

    1 answer 1

    SELECT model, COUNT(message) AS qty FROM Advert WHERE complete = 1 GROUP BY model 

    Read aggregated SQL functions