sql server - Error in SQL sum() -


i have sql line

 select no_, sum(quantity) sold, [shipment date] solddate, [item category code],  description, [description 2] dbo.[3s company a_s$sales invoice line]   [item category code] = '5104' group no_ 

but got error script.

column 'dbo.3s company a_s$sales invoice line.shipment date' invalid in select  list because not contained in either aggregate function or group clause. 

can me why?

try this

   select no_, sum(quantity) sold, [shipment date] solddate, [item category code],    description, [description 2] dbo.[3s company a_s$sales invoice line]     [item category code] = '5104' group no_,[shipment date],    [itemcategorycode], description,[description 2] 

in sql if use column name in select clause except aggregrate function need add columns in group other wise show exception

if want sum no_ column have write subquery aggregarte function , join other columns folows

     select no_ ,quant.sold, [shipment date] solddate, [item category code],    description, [description 2] dbo.[3s company a_s$sales invoice line] inv,   (select no_, sum(quantity) sold dbo.[3s company a_s$sales invoice line]      [item category code] = '5104' group no_) quant      [item category code] = '5104' ,     inv.no_=quant.no_ 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -