MySQL Forums
Forum List  »  Optimizer & Parser

Join? Union? I am so lost.
Posted by: Hank Reardon
Date: September 17, 2012 09:09AM

I have 2 tables. One with 20,000 entries the only with a few hundred.
I need to group and order both tables by the dates and SUM the Debits and Credits in each. (FYI settle is a date.)

something like this:

$query = "SELECT proj3_trades.settle, proj3_cash.date,
ROUND(( SUM(sale) - SUM(purch) ),0) as netTrades,
ROUND(( SUM(credit) - SUM(debit) ),0) as netCashFlow
FROM proj3_trades LEFT JOIN proj3_cash
ON proj3_trades.settle = proj3_cash.date
GROUP BY proj3_trades.settle
ORDER BY proj3_trades.settle ASC";

I unfortunately no SQL guru. And if there is one out there - thank you VERY MUCH.
good karma to all.
Cheers.

Options: ReplyQuote


Subject
Views
Written By
Posted
Join? Union? I am so lost.
2350
September 17, 2012 09:09AM
1245
September 18, 2012 07:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.