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
 Other Forums
 MS Access
 Selection of yes/no statements

Author  Topic 

melanieb
Starting Member

5 Posts

Posted - 2005-05-19 : 15:43:59
I am fairly new at writing SQL statements. I have a table with 10 y/n (testing this with only 3 fields) fields of which I am trying to create a query that only returns the y. My statement though keeps popping up both y and n. I believe I have only a partial statement and still need an iif but dont know the proper code could someone help me with what is Im sure a very simple thing. Thanks so much!

SELECT tblevp.EVPFoodOps, tblevp.EVPNewStoreFormat, tblevp.EVPCTO
FROM tblevp
WHERE (((tblevp.EVPFoodOps)=True)) OR (((tblevp.EVPNewStoreFormat)=True)) OR (((tblevp.EVPCTO)=True))

kaus
Posting Yak Master

179 Posts

Posted - 2005-05-19 : 16:21:18
If you want only records with y on all columns use AND instead of OR --
Go to Top of Page

melanieb
Starting Member

5 Posts

Posted - 2005-05-19 : 16:41:27
I have a feeling I'm going about this completely wrong. Ultimately my goal is to create a report which will show am employee with all of the plans that they are associated with. For instance my code with the 3 fields, the employee may be a yes to only 1 of them. When I create the report based on the query it will show all the fields (y and n). I would like to have a clean report which will show employee and only the fields where there is a yes.
Go to Top of Page

kaus
Posting Yak Master

179 Posts

Posted - 2005-05-19 : 17:03:29
Look into normalizing your data into two or three tables

Employees Table
Employee_id
Employee_Name


Reports Table
Employee_Id
Report

do an inner join on the two tables to pull only the reports for each employee

Select Employee_Name, Report
from Employees
inner join Reports
on Employees.Employee_Id = Reports.Employee_Id
Go to Top of Page
   

- Advertisement -