SELECT ,,,, (SELECT COUNT() FROM WHERE (=) AND ( BETWEEN :pMinDate2 and :pMaxDate2 ) ) as _ FROM , WHERE (.ID = .) AND ( BETWEEN :pMinDate and :pMaxDate)
http://www.sql.ru/forum/1093893/kak-poschitat-kolichestvo-zapisey-s-usloviyami