January 7, 2011 at 8:39 am
I have a query that pulls parent login info and insert into another table.
I want to select unique records based on uique ParentEmail column.
Because we use ParentEMail as login name they have to be unique.
So my select query has below columns:
select familyID, ParentEmail, Parentpassword, Adusername, Adpassword, firstname, lastname, nameID
from tblParents
How can I modify the above query, that if there are duplicated Parent email, I will only pull the first record so this way, all the records will be unique based on ParentEmail column?
Thanks
January 7, 2011 at 9:19 am
;with CTE as
(select familyID, ParentEmail, Parentpassword, Adusername, Adpassword, firstname, lastname, nameID,
row_number() over (partition by ParentEmail order by familyID) as Row
from tblParents)
select *
from CTE
where Row = 1;
Will that give you what you need?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
January 7, 2011 at 9:22 am
Yeah, that should give the desired result.
January 7, 2011 at 9:30 am
Thank you, that's exactly what I want.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply