tommym121
asked on
SQL-How to extract records that have ID is the same
I have made this up to illustrate what I need. I have records of the following format:
Id, field, field2
And the sample data is as follow
1, D1, D2
1, DD1, DD2
2, D12, D22
3, D13, D23
3, DD13, DD23
4, D14, D24
5, D15, D25
5, DD15, DD25
6, D16 , D26
7, D17, D27
I like to create a generic query that can can select only Id = 1, 3,5
I would also like to create a query that take out the records that have no duplicate like Id = 2,4,6,7
Thanks
Id, field, field2
And the sample data is as follow
1, D1, D2
1, DD1, DD2
2, D12, D22
3, D13, D23
3, DD13, DD23
4, D14, D24
5, D15, D25
5, DD15, DD25
6, D16 , D26
7, D17, D27
I like to create a generic query that can can select only Id = 1, 3,5
I would also like to create a query that take out the records that have no duplicate like Id = 2,4,6,7
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am transferring unique data record from one to another table. The duplicate one need further proceassing based on fileld1 and filed2 to extract a single record out of the duplicate.
ASKER
Thanks.
When showing records such as ID=1, are you wanting to keep all instances or just keep/look at D1 or DD1? You can use Min and Max in this case to preserve one or the other.