Home:ALL Converter>How to GROUP BY on Oracle?

How to GROUP BY on Oracle?

Ask Time:2013-09-30T09:19:15         Author:pharaon450

Json Formatter

I need help with sql oracle, my group by doesnt work and i'm working on a shell so i don't have any help.

Can someone tell me how to group this next request by noArticle.

SELECT Article.noArticle, quantite
FROM Article LEFT JOIN LigneCommande ON Article.noArticle = LigneCommande.noArticle
GROUP BY Article.noArticle
/

Thank you

Author:pharaon450,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19085163/how-to-group-by-on-oracle
Lajos Arpad :

You are grouping by a column and then you attempt to use the quantite field which is not group-level, it is record-level. Group by is aggregation and you have to use aggregate columns (the columns you are grouping by or aggregate functions on columns, like sum, avg, count, max or min). You need to aggregate your record-level fields to be able to use them in your projection (select clause). To name an example, your attempt was like trying to get the hair color of American women (of course, there are many American women and they might have different hair color, so it is unnatural and un-wise to attempt to get the value of hair color from the set of American women). Your fixed query is as follows:\n\nSELECT Article.noArticle, sum(quantite)\nFROM Article LEFT JOIN LigneCommande ON Article.noArticle = LigneCommande.noArticle\nGROUP BY Article.noArticle\n",
2013-09-30T02:05:40
Jeanne Boyarsky :

To tie things up, this is the correct SQL.\n\nSELECT Article.noArticle, sum(quantite)\nFROM Article LEFT JOIN LigneCommande ON Article.noArticle = LigneCommande.noArticle\nGROUP BY Article.noArticle\n",
2013-09-30T01:52:44
yy