某大公司的面试题寻答案

txgaozhao 2010-03-25 10:04:50
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();
结果输出什么?
...全文
316 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
鸭梨山大帝 2010-03-26
  • 打赏
  • 举报
回复
6楼中我的回帖 Q1.1 写法有些啰嗦
inner join Student s1 on s1.id = s.id <== 这个完全没必要,呵呵
zhangchunlin_ln 2010-03-26
  • 打赏
  • 举报
回复
1、update student set score=case when score>=60 then 1 when score < 60 then 0 end

2、delete test where id not in (select max(id) from test group by name)
antony1029 2010-03-26
  • 打赏
  • 举报
回复
这也是大公司的题目??
yjp2006 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 lost_painting 的回复:]
Q1:
1.

SQL code

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.

SQL code

Delete student
where id not in ……
[/Quote]



支持。。。
teacher1998 2010-03-26
  • 打赏
  • 举报
回复
这个题目不错啊,记录下
Y_2716 2010-03-26
  • 打赏
  • 举报
回复
这也是大公司面试题..?

很像作业啊..
ycproc 2010-03-26
  • 打赏
  • 举报
回复
汗 我只看看 我不说话
tkscascor 2010-03-26
  • 打赏
  • 举报
回复
public static myclass() 构造函数, 可以使用static 定义的?
nodbon 2010-03-26
  • 打赏
  • 举报
回复
有些难度
netajax1 2010-03-26
  • 打赏
  • 举报
回复
......................瞧瞧,瞅瞅
vip__888 2010-03-26
  • 打赏
  • 举报
回复
像我上学时候的作业
伴老思源 2010-03-26
  • 打赏
  • 举报
回复
update student set score = ( case when score > 60 then 1 else 0 end )
sxiaohui8709253 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 lost_painting 的回复:]
Q1:
1.

SQL code

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.

SQL code

Delete student
where id not in ……
[/Quote]

顶起
xiao_run 2010-03-26
  • 打赏
  • 举报
回复
路过,看看!
jason0019 2010-03-26
  • 打赏
  • 举报
回复
这个公司太大了
我已经受不鸟了
hsn820 2010-03-26
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 huangwenquan123 的回复:]

静态构造函数可以有访问修饰符?
[/Quote]

对头,题目都有错误啦。。。public static myclass() 应该去掉public
结果是
2
3
4
jianke917 2010-03-26
  • 打赏
  • 举报
回复
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

鸭梨山大帝 2010-03-25
  • 打赏
  • 举报
回复
另外:
Q2,代码有问题.

public myclass ? ==> public class myclass

public static myclass() ? ==> static myclass()
鸭梨山大帝 2010-03-25
  • 打赏
  • 举报
回复
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
amandag 2010-03-25
  • 打赏
  • 举报
回复
未测试..
Q1
1)
update student
set score = floor (score / 60)
2)
要看表的数据有多少,重复的数据有多少,解决方案不同
Q2
2
3
4
加载更多回复(4)

62,073

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧