简体   繁体   English

如何从结果表中获取记录?

[英]How to fetch record from resulted table?

I come across a situation where after executing query getting result like this 我遇到这样的情况,在执行查询后得到这样的结果

StdId  Studentname Subcode Grade
1      Pinky       1       A
1      pinky       2       A
1      leena       1       A
1      leena       2       A
1      leena       3       B
2      Rupali      1       A
2      Megha       1       A

Grade are from A to DI want to show record only once when grade is same for same stid,does not matter what is subcode and studentname.If grade is different for same stid,show both record. 成绩从A到DI只想在相同的Stid的成绩相同时显示一次记录,无论子代码和学生名是什么。如果同一Stid的成绩不同,则显示两个记录。 Here I want to show 我想在这里展示

StdId  Studentname Subcode Grade
1      leena       2       A
1      leena       3       B
2      Rupali      1       A

How to do that? 怎么做?

You can do this using the distinct statement. 您可以使用distinct语句执行此操作。

select distinct stdid, Studentname, grade from yourtable 从您的表中选择不同的标准,学生姓名,成绩

Note that it will not be possible to show the Subcode column in this case. 请注意,在这种情况下将无法显示“子代码”列。 If you would like to show this, you would need to decide which one of your multiple values in the Subcode column should be shown and then join back on to your original table. 如果要显示此内容,则需要确定应显示“子代码”列中多个值中的哪个之一,然后再返回到原始表。 I hope that this answers what you were looking to do. 我希望这能回答您的期望。 Thanks.. 谢谢..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM