Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 selecting rows from join

Author  Topic 

anishap
Yak Posting Veteran

61 Posts

Posted - 2011-05-11 : 14:57:21

I have a table with fldtypes,date. I want to select rows of all employees that only have fldtype = 'MMR' and is listed more than once.

I tried the below query but its not working

select e.fldlname,e.fldfname,p.fldtype from employee e, physlog p
where e.fldrec_num = p.fldemployee and
e.fldcomp = 'MED' and p.fldtype NOT IN ('110','110A','MEA','HEPA','COLOR')
order by e.fldlname

any help on this..please let me know

latch
Yak Posting Veteran

62 Posts

Posted - 2011-05-11 : 17:30:40
For more than once:

You can use Group by with having count(fldtype)>1
and with where fldtype='MMR'

The information you supplied is not sufficient to answer, can you provide more information about the tables and values it has.

Thanks
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2011-05-11 : 17:50:17
The query you posted does not seem to relate to the question you asked. Maybe you copied the wrong query?

Mirko

My blog: http://mirko-marovic-eng.blogspot.com/
Go to Top of Page
   

- Advertisement -