?
Solved

How to do a summary of 7 tables

Posted on 2009-05-05
3
Medium Priority
?
351 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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