Solved

SQL Query

Posted on 2013-01-13
2
322 Views
Last Modified: 2013-01-13
Hello, I have the following two tables
 
q2employee_work_schedule
WorkSchedule

q2employee_work_patterns
Work Pattern
 I need to display the people that are not available"NOT working" in the current day, what would be the query for it..

Thanks in advance
0
Comment
Question by:jhonc66
2 Comments
 
LVL 7

Accepted Solution

by:
Phil Davidson earned 500 total points
ID: 38773021
What value would show if an employee was working on a given date?  The working field is varchar(1).  Can that be "Y" or "N" only?  I'm going to assume that is the case.

Here is my best answer (guess?) without knowing more:

SELECT emp_code FROM q2employee_work_schedule
WHERE working = 'N' AND date1 = GETDATE()
--this will return the emp_code for all employees who aren't working today

Do you need more info than emp_code?

You could try this, but it could be slow if q2employee_work_schedule is a big table.

SELECT * FROM q2employee_work_schedule
WHERE working = 'N' AND date1 = GETDATE()


Based strictly on the question, I don't think the second table needs to be involved.
0
 

Author Comment

by:jhonc66
ID: 38773343
in my table I was given the date part and then the time part with just zeros, so when trying to query the table I was not getting any awnser, the way I fixed it was with the following  Query

SELECT * FROM q2employee_work_schedule
WHERE working = 'N' AND date1 = CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question