Solved

Joins

Posted on 2009-04-02
4
190 Views
Last Modified: 2012-05-06
How do pull all rows from the TimeCategory Table
SELECT     Employee.EmployeeNumber, Employee.EmployeeName, Employee.Surname, TimeCategory.TimeCategoryName, DailyHoursTimeCategories.Hours, 

                      DailyHoursTimeCategories.Minutes

FROM         Employee INNER JOIN

                      DailyHours ON Employee.EmployeeID = DailyHours.EmployeeID INNER JOIN

                      DailyHoursTimeCategories ON DailyHours.DailyHoursID = DailyHoursTimeCategories.DailyHoursID RIGHT OUTER JOIN

                      TimeCategory ON DailyHoursTimeCategories.TimeCategoryID = TimeCategory.TimeCategoryID

Open in new window

0
Comment
Question by:u2envy1
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 500 total points
ID: 24048121
SELECT Employee.EmployeeNumber, Employee.EmployeeName, Employee.Surname,
 TimeCategory.TimeCategoryName, DailyHoursTimeCategories.Hours,
 DailyHoursTimeCategories.Minutes
FROM TimeCategory
LEFT OUTER JOIN DailyHoursTimeCategories
ON DailyHoursTimeCategories.TimeCategoryID = TimeCategory.TimeCategoryID
LEFT OUTER JOIN DailyHours
ON DailyHours.DailyHoursID = DailyHoursTimeCategories.DailyHoursID
LEFT OUTER JOIN Employee
ON Employee.EmployeeID = DailyHours.EmployeeID ;
0
 

Author Comment

by:u2envy1
ID: 24048571
Sorry wrong query. Suppose to add the GROUP BY query.
SELECT     Employee.EmployeeNumber, TimeCategory.TimeCategoryName, SUM(DailyHoursTimeCategories.Hours) AS Hours, 

                      SUM(DailyHoursTimeCategories.Minutes) AS Minutes

FROM         Employee INNER JOIN

                      DailyHours ON Employee.EmployeeID = DailyHours.EmployeeID INNER JOIN

                      DailyHoursTimeCategories ON DailyHours.DailyHoursID = DailyHoursTimeCategories.DailyHoursID RIGHT OUTER JOIN

                      TimeCategory ON DailyHoursTimeCategories.TimeCategoryID = TimeCategory.TimeCategoryID

GROUP BY TimeCategory.TimeCategoryName, Employee.EmployeeNumber

Open in new window

0
 
LVL 22

Expert Comment

by:dportas
ID: 24048839
Aren't the joins the same? Just put the GROUP BY and SUMs into my query above.
0
 

Author Closing Comment

by:u2envy1
ID: 31565708
Thx, I added them & it worked perfectly
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query - Oracle 10g - Subract date from next data row 4 48
PL/SQL LOOP CURSOR 3 56
Getting certain data from a string 1 34
SQL Query resolving a string conversion issue 26 37
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

15 Experts available now in Live!

Get 1:1 Help Now