Solved

Join Tables in SQL

Posted on 2013-01-13
3
241 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Upgrading my SSIS package in VS 2012 6 62
sql server query 12 26
SQL Syntax Grouping Sum question 7 27
How to use spatial data types in SQL Server Database project 2 24
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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 combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

820 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