Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to do a summary of 7 tables

Posted on 2009-05-05
3
Medium Priority
?
364 Views
Last Modified: 2012-05-06
I am trying to figure out a way of trying to get a summary of 7 tables in order to add certain fields like a check amount, deductions etc.  Can this be possible?  Please let me know.  Thanks!
0
Comment
Question by:VBBRett
[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
3 Comments
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 24308200
What do you mean by summary?  Please give slight examples of the data in the 7 tables and what you expect results to be or at least explain further.
0
 

Author Comment

by:VBBRett
ID: 24319892
A summary meaning I want certain fields to be added mathematically to get a sum of certain fields.  Basically it's a payroll system I am trying to add up the deductions, the the pay codes, taxes, etc.
Below is an example of a record:

Record-Type  Company  Empid   PLevel  Dept  Checkid  Paycode  DedCode  Hours Wage-amt Ded-amt
      1                 2525        1234     2392              12521      205                          8        20              10
       1                2525        1234     2392               12521                   TAX           8                           5

So basically there are 7 tables like this.  I would like to add things like the hours, the wage-amt, the ded-amt, etc.  There are more fields then what I showed but I just wanted to get a general idea.  What I am trying to do is take each paycheck pay period information table and combine them and add them all up to be a quarterly data table.

Does that make sense?
0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 24320764

You need to know the JOIN condition(s) or JOIN column(s) to JOIN your tables.
After you JOIN all the tables, you may end up with a query like this.
SELECT Record-Type, Company, Empid, PLevel,  Dept,  Checkid,  Paycode,  DedCode,  Hours, [Wage-amt],[Ded-amt],
       <and all other columns from your other tables>
  FROM Table1
 INNER JOIN Table2 ON <JOIN condition>
 INNER JOIN Table3 ON <JOIN condition>
 INNER JOIN Table4 ON <JOIN condition>
 INNER JOIN Table5 ON <JOIN condition>
 INNER JOIN Table6 ON <JOIN condition>
 INNER JOIN Table7 ON <JOIN condition>
Now if you want to add certain fields, you can simply add those fields with +.

SELECT Record-Type, Company, Empid, PLevel,  Dept,  Checkid,  Paycode,  DedCode,  Hours, [Wage-amt],[Ded-amt],
       [Wage-amt] + [Ded-amt] AS Wage_Ded_Amt
  FROM Table1
 INNER JOIN Table2 ON <JOIN condition>
 INNER JOIN Table3 ON <JOIN condition>
 INNER JOIN Table4 ON <JOIN condition>
 INNER JOIN Table5 ON <JOIN condition>
 INNER JOIN Table6 ON <JOIN condition>
 INNER JOIN Table7 ON <JOIN condition>
Hope you got how to implement this.
If you still looking for assistance, provide the field names which you want to add and the JOIN conditions between your tables.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

610 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