创建一个存储过程,查询年龄最大的男生和最小的女生的学号,姓名和年龄 ,谢谢

解决方案 »

  1.   

    select 学号,姓名,年龄 from 表
    where (年龄 in (select max(年龄) from 表 where 性别 = '男')
       or (年龄 in (select min(年龄) from 表 where 性别 = '女')为什么要用存储过程那?
      

  2.   

    --修改一下
    select 学号,姓名,年龄 from 表
    where (年龄 in (select max(年龄) from 表 where 性别 = '男') and 性别 = '男')
       or (年龄 in (select min(年龄) from 表 where 性别 = '女') and 性别 = '女')
      

  3.   

    create proc test 
    as
    select name,age,xb from tb where age in (select max(age) as age from tb group by xb)--exec test  执行