Hi!

 

I got a table, champions, looking like this:

 

id         class      winner_1              winner_2              year

---------------------------------------------------------------------

0          hd         carl                 mattias               1957

1          hs         daniel                                     1982

2          hd         erik                 carl                  1985

3          js         erik                                       1974

 

Imagine I want to see how many times each winner appears where class=hd and which 
year. In this case the answer would be:

 

2 carl 1957,1985

1 mattias 1957

1 erik 1985

 

Please help! Still using old MySQL 3.23.58.

 

Here's some help for starters:

SELECT DISTINCT CASE WHEN c1.winner_1=c1.winner_1 THEN c1.winner_1 ELSE c1.winner_2 
END AS winner FROM champions c1,champions c2

 

/Carl

 

 

 

 

Reply via email to