Solved

SQL Query

Posted on 2013-01-13
2
315 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now