Results 1 to 4 of 4
Thread: Using COUNT in Self Join
Nov 1, 2012, 07:21 #1
- Join Date
- Jun 2012
- 0 Post(s)
- 0 Thread(s)
Using COUNT in Self Join
I'm trying to retrieve total counts for musical band/artist type from a single table called 'artist'.
For the sake of simplification, let's say the table has only two cols a VARCHAR 'artist_id' and an ENUM 'type'.
My problem is, there will never be any matching criteria for which to JOIN upon.
Here's my code which is bringing back empty counts for both:
select count(band.artist_id) as bands, count(combo.artist_id) as combos from artist as band right outer join artist as combo on combo.artist_id = band.artist_id and combo.type = 'combination' where band.type = 'band'