sql >> Databasteknik >  >> RDS >> Mysql

gruppera genom att lägga till värdena

ANVÄND aggregatfunktionen SUM() med GROUP BY :

select ts.name as my_name, ss.step_number, p.specs, SUM(p.price),  ssp.class_id
from optional_system_step  as ss
join system as s on s.system_id=ss.system_id
join category_description  as cd on cd.category_id=ss.category_id
join optional_system_step_product as  ssp on ss.system_step_id=ssp.system_step_id
join product as p on  p.product_id=ssp.product_id
join product_description as pd on  pd.product_id=p.product_id
join template_step as ts on  (ts.template_id=s.optional_template_id and ts.step_number=ss.step_number)
where s.system_id = '15' 
GROUP BY ts.name, ss.step_number, p.spects, ssp.class_id
order by ss.step_number, ssp.class_id; 


  1. Hantera MySQL fulltext specialtecken

  2. MySQL felkod:1175 under UPPDATERING i MySQL Workbench

  3. Hur man uppdaterar mysql-versionen i xampp (fel med innodb_additional_mem_pool_size)

  4. Hur man får flera räkningar med en enda fråga i MySQL