Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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..
Posted
Updated 17-Feb-14 22:34pm
v2
Comments
Krunal Rohit 18-Feb-14 4:37am    
And what are you getting as a result ?
King Fisher 18-Feb-14 5:25am    
why do you need like this ?
nandakishoreroyal 18-Feb-14 6:57am    
I inserted duplicate data in the table..

so i need only distinct data.

1 solution

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
 
Share this answer
 
Comments
nandakishoreroyal 18-Feb-14 6:56am    
Dear ShridharPanigrahi,

actually i have 25 columns.

Is there any simple way to retreive data with out mentioning columns.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900