Using SQL to ignore all employees without certain deduction code -


i trying pull report database using sql. of employees have multiple deduction codes, want ignore deductions on employee has deduction. i.e. want pull employees not have 33. of course can pull not 33 other deductions employees have 33.


where ( ((viewpoint.dbo.preh.employee not in (select viewpoint.dbo.preh.employee viewpoint.dbo.prdt.edlcode = 33))

here 1 generic approach excluding employees have deduction 33.

where empid not in (select empid mytable deductionid = 33) 

this approach excludes employee identifier employee has deduction 33. of course, since haven't posted sql, approach need modified suit specific scenario.

update

based on new information added question, here more specific answer:

where viewpoint.dbo.preh.employee not in (select prdt.employee viewpoint.dbo.prdt prdt prdt.edlcode = 33) , viewpoint.dbo.prdt.prenddate &sparm01 --what this?  missing equals sign? , viewpoint.dbo.preh.activeyn ='y'  , viewpoint.dbo.prdt.prco ='1'  order viewpoint.dbo.preh.lastname, viewpoint.dbo.preh.firstname 

notes

  • the stuff follows not in subquery, , needs follow basic select pattern.
  • since have , conditions (no or conditions) in clause, there's no need have of parentheses. need parentheses around subquery.
  • i've added comment 1 part of condition appears missing equals sign.

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -