Solved

How to do a summary of 7 tables

Posted on 2009-05-05
3
276 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
3 Comments
 
LVL 59

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 40

Accepted Solution

by:
Sharath earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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 …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

19 Experts available now in Live!

Get 1:1 Help Now