Solved

Joins

Posted on 2009-04-02
4
213 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
[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
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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