Hello!

I am building a query to get a monthly total for receipts and receipts plus
TAX.
My problem is the TAX, it can be different for each receipt.
I need help on including and relating each TAX value/id with each receipt,
like receipt_items.price * 1.21 etc.

The tables are like the following example:

Table receipts:
id | id_tax | date
1    1        2005-12-31
2    1        2006-01-01
3    2        2006-01-25
...
Table receipt_items:
id | id_receipt | price (exc tax)
1    1            1000
2    2            1000
...
Table tax:
id | tax (%)
1    19
2    21

So far I have:

SELECT 
        SUM(receipt_items.price) AS total , 
        (SUM(receipt_items.price) * [-help here-]) AS total_plus_tax 
FROM 
        receipt_items, receipts
WHERE 
        receipt_items.id_receipt = receipts.id 
        AND MONTH(receipts.date)=".$month." 
        AND YEAR(receipts.date)=".$year."


Thanks in advance.
Pedro.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to