Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : Paycheck multi table join with sum and group?Search Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 Paycheck multi table join with sum and group? 
 Author   Message 
  pamsauto 
  
 Group: Members 
 Posts: 2 
 Joined: 2008-02-22 
 Profile
 Posted : 2008-02-22 01:04:38

So I jumped in feet first and got the read version of QODBC and am learning real fast it is not like running QB in SQL!   I understand why, but I need to know if my ultimate goal is even obtainable.   I have a company file that is holding 5 years of data.  I am not sure how to get the row stats of the file as if I run the VB Demo and do a select count(*) against any large tables , I never get results.  

 

 

Example would be SELECT count(*) FROM checkitemline - This return Zero.   Seems wrong since there is 40K checks in the check register, and takes 5 minutes to run the query.   Is there a row limit on table scans?

 

 

But the goal of all this lies here.   I am tasked to gather employee pay amounts grouped by paycheck period and separated into departments for the last 3 years.   Prior until right now, no classes existed, and no checks were classed when written.   I edited every employee and set their class to one of 5 classes to sort them out.  This of course does nothing to the payments written to them in the past, so I was hoping that a join like this would work.

 

 

I am not sure of all the tables required as this is just a guess but join these tables

 

 

Employee

 

 

Check

 

 

CheckItemLine

 

 

Class

 

 

and since all paychecks are written once a week at the same time

 

 

Group them by date in the check table

 

 

and Sum them by class

 

 

So once I figure out the SQL for this will it even be executable on a QuickBooks file that is 200mb in size?

 

 

 

 

 

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-02-22 08:14:43
VB Demo only works with queries of 10,000 returned rows or less. The CheckItemLine table only provides the line item detail for a check while the CheckExpenseLine table actually provides the expense line detail for a check. It might be more useless doing:

SELECT count(*) FROM check

As far as the task ACTUALLY in hand is concerned, try something like this:

SELECT Employee.PayrollInfoClassRefFullName, sum(Transaction.Amount) as Amount 
FROM Transaction, Employee
where Transaction.EntityRefListID=Employee.ListID
and Transaction.TxnType='Paycheck'
and (Transaction.TxnDate >= {d'2007-01-01'} and Transaction.TxnDate < {d'2008-01-01'})
Group by Employee.PayrollInfoClassRefFullName

 

 

  Top 
  pamsauto 
  
 Group: Members 
 Posts: 2 
 Joined: 2008-02-22 
 Profile
 Posted : 2008-02-23 06:45:31

Tom-

Thanks for helping so much.   Your SQL was very close to what I needed.    I will post the final SQL so if anyone sees this they wil have what they need.   This SQL returns a payroll date, the class, and the sum of payroll for the class that the employee is currently in for the specified date range.

 

SELECT

Employee.PayrollInfoClassRefFullName,

sum(Transaction.Amount) as amount,

Transaction.TxnDate

FROM Transaction, Employee

where Transaction.EntityRefListID=Employee.ListID

and Transaction.TxnType='Paycheck'

and (Transaction.TxnDate >= {d'2007-10-05'}

and Transaction.TxnDate < {d'2008-12-31'})

and transaction.amount>0

group by Employee.PayrollInfoClassRefFullName,Transaction.TxnDate

order by Employee.PayrollInfoClassRefFullName,Transaction.TxnDate

Enjoy!

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to