Solved

SQL Query

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.

760 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