Solved

Join Tables in SQL

Posted on 2013-01-13
3
233 Views
Last Modified: 2013-01-15
Hello I have the following query which is giving me the data from the people not working on Today.

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

 but is giving me an employee Code "emp_code" which is fine but I need a name, there is another table called dbo.q2employees, how can I join these two tables to get the preferred name "preferred_name"  and surname

Thanks
0
Comment
Question by:jhonc66
  • 2
3 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38773395
SELECT q2employee_work_schedule.* ,q2employees.*
FROM q2employee_work_schedule
Inner join q2employees on q2employee_work_schedule.emp_code =q2employees.emp_code
WHERE working = 'N' AND date1 = CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38773396
SELECT q2employee_work_schedule.* ,q2employees.preferred_name,q2employees.surname
FROM q2employee_work_schedule
Inner join q2employees on q2employee_work_schedule.emp_code =q2employees.emp_code
WHERE working = 'N' AND date1 = CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME)
0
 

Author Closing Comment

by:jhonc66
ID: 38780845
Thanks a lot
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

Title # Comments Views Activity
Select2 jquery help 9 45
MS SQL server Varchar and nvarchar, GMT_DATE 23 50
Ranking Based On Value 3 29
Numeric sequence in SQL 14 37
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…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

705 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

13 Experts available now in Live!

Get 1:1 Help Now