Jump to content

[SOLVED] report products or cumulate same rows


sheriff

Recommended Posts

hi all ...

 

I have a list generated from mysql with products what have not delivered to customers.

 

how can i tell to php or mysql  ??? to cumulate the items with the same id and to calculate the quantity of the items ?

exemple:

 

Nr.    ID      The product                        UM    QTY    ord nr

1  88  Antene pentru plase volei  per  2  767762

2 88 Antene pentru plase volei  per 1 791688

3 305 Aparat de măsurat detenţa  buc 1 264954

4 305 Aparat de măsurat detenţa  buc 2 659272

5 286 Aparat de ramat HAMMER buc 2 767762

6 286 Aparat de ramat HAMMER buc 1 419495

7 286 Aparat de ramat HAMMER buc 1 430298

8 286 Aparat de ramat HAMMER buc 1 219941

9 286 Aparat de ramat HAMMER buc 7 825287

10 286 Aparat de ramat HAMMER buc 1 791688

 

and i want to show something like:

1  88  Antene pentru plase volei  per  3  767762

2 305 Aparat de măsurat detenţa  buc 3 264954

35 286 Aparat de ramat HAMMER buc 13 767762

 

the code what i use now:

 

$query = "select prod_com.pr_id, prod_com.ord_nr, prod_com.cmd_id, prod_com.pr_qty, products.pr_name, products.pr_desc, products.pr_um, products.pr_price from prod_com, products WHERE prod_com.pr_id=products.pr_id and prod_com.pr_id=prod_com.pr_id and prod_com.pr_date_deliv is NULL ORDER BY products.pr_name";

 

thanks!

The solution is:

$query = "SELECT prod_com.pr_id, prod_com.ord_nr, prod_com.cmd_id, prod_com.pr_qty, sum(prod_com.pr_qty) AS total_quantity FROM prod_com GROUP BY prod_com.pr_id";

 

the reference:

http://www.thescripts.com/forum/thread647763.html

 

Very cool thing !

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.