问题是这样的:
请写出在class表中查找满足如下条件的记录的SQL语句:
1 返回字段c_name,c_stu
2 返回记录数:前5条
3 查询条件:c_stu值大于30,并且c_type值为真,并且c_name字段值中有“二班”两个字
4 查询结果按c_stu正排序,按c_type倒排序(注:在正排序时请不要省略排序关键字)
希望大家共同完成这个题目,谢谢

解决方案 »

  1.   

    1.select c_name,c_stu from table
    2.select top 5 * from table
      

  2.   

    select top 5 c_name,c_stu
    from class 
    where c_stu > 30 and c_type = 1 and c_name like '%二班%'
    order by c_stu asc,c_type desc
      

  3.   

    3.select * from table where c_stu > 30 and c_type = true and c_name like '%二班%'4.没看明白?select * from table order by c_stu asc, c_type desc
      

  4.   

    1 .Select c_name ,c_stu From class
    2 Select Top 5 * From class
      Order BY Id
    3 Select * From Class
      Where c_stu > 30 
      and C_type is true
      And C_Name like '%二班%'(Or CharIndex(C_name , '二班' , 1) > 0)
    4  Select * From Class
      Where c_stu > 30 
      and C_type is true
      And C_Name like '%二班%'(Or CharIndex(C_name , '二班' , 1) > 0)
      Order By c_stu Asc , c_type desc