Reputation: 63
I have the following database:
Drager || Price
----------------
LP || €16
CD || €9
LP || €21
S || €12
I want to count the "Drager" and make a table that looks like this:
Drager || Number || Price
LP || 2 || €37
CD || 1 || €9
S || 1 || €12
My question now is: how can I count all the "dragers"?
I got this query but how can I count them separetaly?:
$query = "SELECT COUNT(Medium) FROM platen";
And how can I get the total price?
I appreciate your help!
Upvotes: 0
Views: 103
Reputation: 53
I think this is what your looking for;
$query = "SELECT drager, COUNT(drager),SUM(price) FROM platen GROUP BY drager";
Upvotes: 1
Reputation: 9618
Should be as simple as:
SELECT Drager
, COUNT(*) AS Number_of_Dragers
, SUM(price) AS Price_of_Dragers
FROM your_table
GROUP BY Drager
Upvotes: 3