基于特定列的不同 [英] distinct based on particular column

查看:119
本文介绍了基于特定列的不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的格式为



ID PID 名称 < b>年龄

1 1 A 10

2 2 B 20

3 3 C 30

4 4 D 40

5 1 A 10

6 2 B 20

7 3 C 30

8 4 D 40



我想要基于PID的独特数据。



我需要输出为



ID PID 名称 AGE
1 1 A 10

2 2 B 20

3 3 C 30

4 4 D 40





请帮帮我..



请写下查询..

I have table in format of

ID PID Name AGE
1 1 A 10
2 2 B 20
3 3 C 30
4 4 D 40
5 1 A 10
6 2 B 20
7 3 C 30
8 4 D 40

I want the distinct data based on PID.

I need the output as

ID PID Name AGE
1 1 A 10
2 2 B 20
3 3 C 30
4 4 D 40


Please help me..

Please write query..

推荐答案

ID列是唯一的,所以如果你避开ID列,那么下面的简单查询将完成其余的工作:

选择不同的PID,Name,来自餐桌的年龄



您想要身份证吗?也会在输出中显示?如果是,则为匹配的PID选择哪个ID,例如对于PID:1有2个ID 1和5.



-SP
The ID column is unique, so if you avoid the ID column then a simple query like below would do the rest:
select distinct PID, Name, Age from table

Do you want the ID to also be shown at the output? and if yes which ID to be selected for the matching PID e.g. for PID : 1 there are 2 ID's 1 and 5.

-SP


这篇关于基于特定列的不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆