I'm trying to write one select statement to pull all of the data I
need for a particular report.  The first part of the statement pulls
various things from a transactions table.  It works fine.  As soon as
I add the code to access the inventory table as well, though, I end up
with numbers that are way too large.

I know I'm probably missing something obvious, but here are the select
statements below if anyone has any insight.  The first is just
transactions table, and seemingly works.  The second is the trouble
maker.

The goal is to sum all the listed transaction table fields for the
given date, but the get the current total of inventory value,
regardless of any date constraints on inventory.

SELECT SUM(total) as Total, SUM(tax) as Tax, SUM(subtotal) as
Subtotal, SUM(cost) as COGS, (SUM(total) -
SUM(ext_cost))/SUM(total)*100 as GP FROM trx where trx.date =
CTOD('09/30/06')

SELECT SUM(total) as Total, SUM(tax) as Tax, SUM(subtotal) as
Subtotal, SUM(cost) as COGS, (SUM(total) -
SUM(ext_cost))/SUM(total)*100 as GP,
SUM(inventory.onhand*inventory.avg_cost) FROM trx, inventory where
trx.date = CTOD('09/30/06')

Thanks in advance!

Justin


_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to