高手请进 动态语句的问题
大家好! 
          我想实现一个动态查询 
          有a,b两个表            
          select   (select   count(*)   from   a   where   b.condition),*   from   b            
          其中b.conditioin   为   表b的字段,值为   a   表中子段的筛选条件如:(性别   =    '男 ') 
          上面语句是有语法错误的,不知各位大侠是否明白我的意思?   
------解决方案--------------------where b.condition ???没寫完整...
------解决方案--------------------select (select count(*) as cs from a where b.condition),* from b
------解决方案--------------------declare @condition varchar(200) 
 set @condition = '性别= ' '男 ' ' ' 
 exec( 'select (select count(*) from a where b. '+@condition + '),* from b ')
------解决方案--------------------好像行不通啊。因为condition里面还是有问题的。比如性别=男应该改为性别= '男 ' 
 然后 
 select @s= 'select count(*) from a where '+b.condition from b where ... 
 exec(@s)