8)重新運行相同的報告,併爲這三家公司分別給出2014和2015年的數字。按年份訂購,然後在每年內從最高到最低訂單數量。SQL幫助編碼多年
SELECT count(orders.orderid)
, customers.companyname
, to_char(orders.orderdate, 'Y') as Year
FROM northwinds.orders
JOIN northwinds.customers
ON customers.customerid = orders.customerid
JOIN northwinds.orderdetails
ON orderdetails.orderid = orders.orderid
WHERE orders.orderdate between '1-JAN-14' and '31-DEC-15'
AND customers.companyname = 'Rattlesnake Canyon Grocery'
OR customers.companyname= 'Around the Horn'
OR customers.companyname='Island Trading'
GROUP
BY customers.companyname
AND to_char(orders.orderdate, 'Y')
ORDER
BY count(orders.orderid) DESC
, to_char(orders.orderdate, 'Y')
;
當我運行此,我收到錯誤:
Error: [Oracle][ODBC][Ora]ORA-00933: SQL command not properly ended
你在用什麼DBMS? – Zi0n1
我通過Oracle使用SQL。 – Marisa
如果您使用的是像SQLDeveloper這樣的GUI工具,他們還會提及錯誤的行號,這將有助於識別問題。 – Maverick