简体   繁体   中英

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. 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.

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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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