Monthly Stats Query

    Date: 04/26/06 (MySQL Communtiy)    Keywords: no keywords

    [UPDATE - no error]

    SELECT DATE_FORMAT(invoice_main.invoice_date, "%Y-%m") AS inv_date,
    invoice_main.invoice_number,
    SUM((invoice_main.mileage*invoice_main.mileage_rate)+ invoice_main.groceries_value - invoice_main.discount_value) AS reimbursements,
    invoice_items.service_type,
    invoice_items.rate,
    invoice_items.start_time,
    invoice_items.end_time,
    SUM(invoice_payments.pmt_amount) AS payments
    FROM invoice_main
    LEFT JOIN invoice_items ON invoice_main.invoice_number = invoice_items.invoice_number
    LEFT JOIN invoice_payments ON invoice_main.invoice_number = invoice_payments.invoice_number
    WHERE DATE_FORMAT(invoice_main.invoice_date, "%Y-%m") = DATE_FORMAT(CURRENT_DATE(), '%Y-%m')
    GROUP BY invoice_main.invoice_number



    SOLVED "FROM invoice_main" missing...

    Just dont know if this is the right logic now :) - I'll let you know

    Source: http://community.livejournal.com/mysql/93828.html

« Admin stuff || SQL Help »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home