Q1.有一个学生表student,字段分别有自增主键id,学生名称name,分数score,记录时间rowdate
1)用一条语句,把及格(score>60)的记录的score改成1,把不及格的score都改成0,注意只能用一条语句
2)把学生名字重复的记录删除掉,每个名字只保留一条记录
Q2.
public myclass
{
   public static int num=1;
   public static myclass()
   {
      Console.WriteLine(++num); 
   }
   public myclass()
   {
      Console.WriteLine(++num); 
   }
}myclass a=new myclass();
myclass b=new myclass();
结果输出什么?

解决方案 »

  1.   

    本帖最后由 amandag 于 2010-03-26 08:46:28 编辑
      

  2.   

    Q1:
    1.Update s set s.score = case when s1.score > 60 then 1 else 0 end
    from Student s
    inner join Student s1 on s1.id = s.id
    2.Delete student
    where id not in 
    (
    select max(id) from student group by name
    )
    Q2:
    执行步骤:
    ==> myclass a=new myclass(); 
    ==> num =1 
    ==> public static myclass() ++num num = 2; (writeLine)
    ==> public myclass() ++num num=3; (writeLine)
    ==> myclass b=new myclass(); 
    ==> public myclass() ++num; num=4; (writeLine)Result:
    2
    3
    4
      

  3.   

    另外:
    Q2,代码有问题.public myclass ? ==> public class myclasspublic static myclass() ? ==> static myclass()
      

  4.   

    1、update student set score=case when score>=60 then 1 when score < 60 then 0 end2、delete test where id not in (select max(id) from test group by name)
      

  5.   

    6楼中我的回帖 Q1.1 写法有些啰嗦 
    inner join Student s1 on s1.id = s.id <== 这个完全没必要,呵呵
      

  6.   

    1.update student set score = floor (score / 60)
    2.delete test where id not in (select max(id) from test group by name) 
    Q2.
    2
    3
    4
      

  7.   

    update student set score = ( case when score > 60 then 1 else 0 end )
      

  8.   

    public static myclass() 构造函数, 可以使用static 定义的?
      

  9.   


    对头,题目都有错误啦public static myclass() 应该去掉public
    结果是
    2
    3
    4