Solved

SQL Query

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSIS I need to get the most old file from a folder in the SSIS package. 3 23
SqlServer no dupes 25 34
string fuctions 4 25
Find SQL query used by application 3 16
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

816 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

12 Experts available now in Live!

Get 1:1 Help Now