Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

sum - How to Rollup Data from Sqfite for Expansion Tile - Flutter

I have a sqflite table which holds the daily transactions. I would like to show the the trasactions in Flutter using the Expansion Tile.

The Card inside the ExpansionTile will be showing the Rolledup sum of that category. On expanded, the child Card will show the total of the SubCategory.

The transaction table has the following columns and data.

id   MainCategory SubCategory Amount
1    All Banks    BanK 1       500
2    Credit Cards Card 3       200
3    All Banks    Bank 1       300
4    All Banks    Bank 1       400
5    All Banks    Bank 2       800
6    Credit Cards Card 3       400
7    Credit Cards Card 2       100

What I would like to show in the ExpansionTile is as follows:

 -    All Banks    2000
 -----> Bank 1           1200
 -----> Bank 2            800
 
  -    Credit Cards   700
 -----> Card 2            100
 -----> Card 3            600

I tried using ROLLUP function, but invariably, this is throwing an error in SQFlite.

I have two different queries - one to sum on MainCategory and the other to SUM on MainCategory and SubCategory.

Wondering what is the right way to handle this in flutter. Thanks in advance for the support.

question from:https://stackoverflow.com/questions/65859049/how-to-rollup-data-from-sqfite-for-expansion-tile-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...