两条SQL语句

select count(*) as "所查人数"
  from (select * from table_a a, table_b b where a.pid = b.pid) t
 where t.name like '张%'
   and t.age >= 24
   and t.age <= 50;

select avg(t1.age) as "所查平均年龄"
  from (select * from table_a a, table_b b where a.pid = b.pid) t1
 where t1.name like '张%'
   and t1.sex = '';

 

转载于:https://www.cnblogs.com/geniussoft/archive/2012/12/06/2804342.html

你可能感兴趣的:(两条SQL语句)