Reputation: 3
I have the following table. Now I want to count the amount of each value in this table.
value | count |
---|---|
1 | 1 |
-1 | 1 |
2 | 1 |
3 | 1 |
-1 and 1 should be seen as 1, so the output should be
value | count |
---|---|
1 | 2 |
2 | 1 |
3 | 1 |
Does someone know a quick fix?
Upvotes: 0
Views: 34
Reputation: 754
Grouping by value, and making such values the absolute value so you ignore the negative sign:
SELECT
ABS(VALUE) VALUE, COUNT() COUNT
FROM
table
GROUP BY
ABS(VALUE)
Upvotes: 1