The problem with doing a database query is that the 'Type' field is a bit-vector for a number of different options, stored/encoded as an integer. I'm pretty good with SQL, but I'm not sure how to turn the integer number into meaningful fields inside an SQL query (although I can do this with Perl quite easily).