I want to count brand comparisons.
I have 2 columns and they have brand ids.
My table
id | brand_1_id | brand_2_id |
---|---|---|
1 | 502 | 333 |
2 | 11 | 16 |
3 | 16 | 11 |
4 | 502 | 333 |
5 | 333 | 502 |
Code I use
SELECT brand_1_id, brand_2_id, COUNT(*) AS HowManyCount FROM comparisons GROUP BY brand_1_id, brand_2_id ORDER BY HowManyCount DESC;
Results
brand_1_id | brand_2_id | HowManyCount |
---|---|---|
502 | 333 | 2 |
333 | 502 | 1 |
11 | 16 | 1 |
16 | 11 | 1 |
but I want
333,502 and 502,333 should be taken as the same
brand_1_id | brand_2_id | HowManyCount |
---|---|---|
502 | 333 | 3 |
11 | 16 | 2 |
Is something like this possible ?
Thank you.
New contributor
Jalou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.