Solved

SQL Query

Posted on 2013-01-13
2
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

752 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