I have a scenario where I got multiple columns with similar content. I want to count how many distinct values are there in all the columns. Slightly different to the below linked case where content of two columns are looked at as a single attribute/element.
Counting DISTINCT over multiple columns
My table is as above. I need to go thru all club columns and count how many distinct clubs there are.
The below code I managed only counts distinct rows. Not individual distinct elements in each column.
select count(*) from( select distinct Club1 Club2 from StudentClubs) as ClubCount
The above returns 6
I need it to output 12 as there are 12 clubs in total.
Thanks in advance.