I'm trying to create a view, but when i include the "group by" function, it says that there is an error at line 2 saying that it is not a group-by expression. If i comment out the "group-by" function, then it says theres an single-group group function error in the view. how can i fix this?
CREATE or REPLACE VIEW bestseller_view
AS SELECT e.empl_name,
NVL((sum((si.amt_paid+a.ao_price)-fs.purchase_cost+a.ao_purchase_price)*se.salary_comm),0) sales_commission,
COUNT(si.s_empl_id) vehicles_sold
FROM for_sale fs
JOIN sales_invoice si ON fs.vehicle_id = si.vehicle_id
JOIN sales_empl se ON si.s_empl_id = se.empl_id
JOIN purchased_ao pao ON si.sales_invoice_id=pao.sales_invoice_id
JOIN add_ons a ON pao.ao_id=a.ao_id
JOIN employee e ON se.empl_id=e.empl_id;
GROUP BY si.s_empl_id;