I have a table with with 2 unique linked table ids. I get the results I want with GROUP BY but when I count I only get the number of each group.
When I do:
SELECT COUNT(id) FROM my_table GROUP BY first_linked_table_id, second_linked_table_id
I get as results 1, 2, 3, 1 but I want 4 as a result.
I tried DISTINCT but I think that only works with one column
DISTINCTworks with any number of columns, but it won't change much asDISTINCTis usually implemented byGROUP BYunder the hood. Please include some sample data here.DISTINCT field1, field2, but in any case this is irrelevant to your question.