'I have a SUM function in my SELECT but don't want it to show
I want to see the companies which deliver the most sold items in my DB.
Currently i have this Code:
SELECT L."Firma", SUM("B"."Anzahl")
FROM "Bestelldetails" B, "Artikel" A, "Lieferanten" L
WHERE L."Lieferanten-Nr" = A."Lieferanten-Nr"
AND A."Artikel-Nr" = B."Artikel-Nr"
GROUP BY L."Firma"
ORDER BY 2 DESC
The Output that i get:
| Firma | 2 |
|---|---|
| Company 1 | 2756 |
| Company 2 | 2377 |
| Company 3 | 2063 |
| ...many more... | ..XXX.. |
The Output that i want:
| Firma |
|---|
| Company 1 |
| Company 2 |
| Company 3 |
| ...many more... |
But i don't want the row with the number 2 to show. I just want the Company-Names to show. How would i do so?
Solution 1:[1]
select Firma from
(
SELECT L."Firma", SUM("B"."Anzahl")
FROM "Bestelldetails" B, "Artikel" A, "Lieferanten" L
WHERE L."Lieferanten-Nr" = A."Lieferanten-Nr"
AND A."Artikel-Nr" = B."Artikel-Nr"
GROUP BY L."Firma"
ORDER BY 2 DESC
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Larnu |
