sql - What is 'keyword' is missing from this query? -


this have;

select c.customerfn, c.customeremail, p.productname,  sum(p.unitsonstock + p.unitsordered) "all units" customer c inner join order o  c.customerid=o.customerid inner join orderdetails d   o.orderid=d.orderid inner join product p  p.productcode=l.productcode orderdate <= '2015-03-15'  order productname; 

when enter database throws "missing keyword" error @ fourth line. tell me i'm missing

join performed using on clause, not where:

... customer c inner join order o on c.customerid=o.customerid inner join orderdetails d on o.orderid=d.orderid inner join product p on p.productcode=d.productcode orderdate <= '2015-03-15'     ... 

the where clause comes after join should used have in query.

apart problem join there problem using sum without grouping. want like:

select c.customerfn, c.customeremail, p.productname,         sum(p.unitsinstock + p.unitsordered) "all units" customer c inner join order o on c.customerid=o.customerid inner join orderdetails d on o.orderid=d.orderid inner join product p on p.productcode=d.productcode orderdate <= '2015-03-15' group customerfn, customeremail, productname order p.productname; 

use of sum function implies group by clause. every column selected not part of aggregate function sum must present in group by clause.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -