0
我想生成一個報告來按月統計訂單數和訂單數。訂單和訂單行數報告
在orders
表我已經order_id
和order_date
領域
在order_lines
表,我有order_lines_id
,order_id
我希望報表生成這樣的:
Year, Month, NumberOfOrders, NumbersOfLines
2015 1 4 55
2015 2 3 6
我有嘗試了下面的SQL,並沒有工作我怎麼想成爲
SELECT
Year(orders.order_date) as Year,
Month(orders.order_date) as Month,
count(orders.order_id) as NumberOfOrders,
count(order_lines.order_lines_id) as NumbersOfLines,
FROM `orders`
LEFT JOIN order_lines On order_lines.orders_id = order_lines.order_lines_id
group by sales.sales_id, order_lines.order_lines_id
快如箭! +1 –
@JorgeCampos謝謝..誰降低價格,爲什麼? – sagi
任何人都可以解釋爲什麼我用正確的答案兩次downvoted? – sagi