php - SUM subcategory -


I have a query that gives me the following data.

1 - Category 1

1.1 Sub Category 1

1.1.1 - Sub Sub Category 1 $ 10

1.1.2 - Sub Sub Category 2 $ 10

1.1.3 - Sub Sub Category 3 $ 10

1.2 - Sub Category 1

1.2.1 - Sub-Sub Category 1 $ 20

1.2.2 - Sub Sub Category 2 $ 20

1.2.3 - Sub-Sub Category 3 $ 20

2 - Category 2

2.1 - Sub Category 2

2.1.1 - Sub Sub Category 1 $ 30

2.1.2 - Sub-Sub Category 2 $ 30

2.1.3 - Sub-sub-category 3 $ 30

I want my query returned under sub-category total. It was shown below as a prefix:

1 - Category 1

1.1 sub category 1

1.1.1 - sub sub category 1 $ 10 <

Total $ 30 1.2 - Sub Category 1 1.2.1 - Sub Sub Category 1 $ 20

1.2.2 - Sub Sub Category 2 $ 20

1.2.3 - Sub-Sub Category 3 $ 20 < /

Total $ 60

2 - Category 2

2.1 - Sub Category 2

2.1.1 - Sub-Sub Category 1 $ 30

2.1.2 - Sub Sub Category 2 $ 30

2.1.3 - Sub-Sub Category 3 $ 30

Total $ 90

I used MySQL Using PHP with

My query This is how

  SELECT cm.cat, cm.subcat, cm.subsubcat, cm.title, cm.typo, (SELECT SUM (rg.value) tt_record rg WHERE rg.cat = Cm.cat and rg.subcat = cm.subcat and rg.subsubcat = cm.subsubcat and rg.igreja = 'XXX' and MONTH (RGD)) = 01 and year (rgdate) = 2015), (STM ( RG value) is tt_record rg WHERE rg.cat = cm.cat and rg.subcat = cm.subcat and cm.subsubcat faucet and Rg.igreja = 'XXX' and MONTH (rg.date) = 01 and YEAR (rg) .date) = 2015) Sub-category, (SELECT SUM (rg.value) tt_record rg WHERE rg.cat = cm.cat and cm subtot is faucet and cmbsbat is null and RG.Egreza = 'XXX' and month (rgdata) = 01 and year (Rgd) = 2015) TT_KTA_MA Stre centimeter join CT from TTY_Cata_meister cm2.cat = cm .cat and cm2.subcat = cm.subcat and cm2.subsubcat = cm.subsubcat ORDER BY cm.cat, cm.subcat, cm.subsubcat  

tt_cta_mestre is the table where I store my categories, sub categories and sub sub categories. They have cat fields, subcounts, subbucks if the category subcontract field and subback will be empty.

If the subcategory subbabet field is empty.

If the sub-bank has three field populations.

The table where I record the record is output with input and their values. Each record is linked to a subsubcat


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -