For instance I have two tables in a music database.

Table album and table track.

Each track record has (amongst other things), an album_id and an artist_id

Each album record has a unique album_id

In order to spot which albums are by 'various artists' I want to count the number of distinct artist_id's which belong to each album.

Such that two or more track records with the same album_id but with differing artist_id's should signal that I can flag the album as 'various artists'

I can do it with multiple queries but I'm seeking the elegant all in one query.


Question: Meaning and best case usage of 'Out of the blue'
Answer: It means "coming on you without warning" as if falling from the sky directly onto your head. "The blue" in this case is the blue of the sky.

EDIT


  out of the blue happening suddenly and unexpectedly Then one day, completely out of the blue, I had a letter from her. : The attack came out of a clear blue sky.


This is probably derived from the old idiom "a bolt from the blue":


  bolt from the blue
  Fig. a sudden surprise. (Alludes to a stroke of lightning from a cloudless sky.) Joe's return to Springfield was a bolt from the blue. | The news that Mr. and Mrs. King were getting a divorce struck all their friends as a bolt from the blue.


I have heard this did not originally refer to lightning, but to crossbow bolts in medieval times raining down after having been shot vertically. I'm not close to my reference materials at the moment, however, so I will look later.