April 7, 2010 at 4:41 pm
Find all rows where the value in one column only occurs once
Employee Sections
harshan 12
harshan 25
mileen 2
ajay 19
Would it be possible to do a select on this table and only display rows where Employee occurs only once,:result will be like this
Employee Sections
mileen 2
ajay 19
harshan 12 (select first one)
Any hints?
April 7, 2010 at 4:53 pm
VG-619426 (4/7/2010)
Find all rows where the value in one column only occurs onceEmployee Sections
harshan 12
harshan 25
mileen 2
ajay 19
Would it be possible to do a select on this table and only display rows where Employee occurs only once,:result will be like this
Employee Sections
mileen 2
ajay 19
harshan 12 (select first one)
Any hints?
Like this:
SELECT Employee, MIN(Sections) as Sections
FROM EmployeeSections
GROUP BY Employee
HAVING COUNT(*) = 1
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
April 7, 2010 at 4:55 pm
It's a little bit more work if you really only want the first Section.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply