Doubt using the GROUP BY function

Hey guys, sorry for the weird question but I just learnt the GROUP BY function and I didn’t understand a part of it.

Whenever I use SELECT * in a table and proceed to GROUP BY price or by category, I noticed that only one app name is displayed, even though there are many apps in the same price or category . How does SQL choose this?

Thank you

As SQL works top down when searching, the one you see returned should be the last value with that equivalent grouping value i.e. the last one in the table at price 3.99.

However, if you are using GROUP BY then there’s not a whole lot of use for these values. If you’re grouping by price, then there will be multiple apps at this pricepoint and as such keeping that column selected is not useful. I would recommend selecting specific columns if you wish to use group by, for example

SELECT price, COUNT(*)
FROM apps
GROUP BY price;

would return the number of apps at each price point. To answer your question though, it selects the last value in the table.