Improved sql query speed for one specific request

Hi! I improved a bit the sql request for sql query type 2. You had one sub-select for counting entries in categories, I replaced it with a simple count function. There is the nearly same request just below the one I modified (in the else block) that could be improved the same way.