How to get the sum of of particular column using group by functionality while pulling data from sql using jdbc?

1 回表示 (過去 30 日間)
I am retrieving data from the database using a select query. I am able to get the data using curs.Data. However, now I want to find the sum of a particular column using group by clause on two columns.
Example: A=[1, 2.5, 3;1, 2.5, 4;1, 1.5, 3;2, 2.5, 3;2, 3.5, 4 ] then I want the output like B=[1, 2.5, 7; 1,1.5,3;2, 2.5, 3;2, 3.5, 4 ]
  1 件のコメント
Geoff Hayes
Geoff Hayes 2017 年 2 月 9 日
Aishwarya - so if two rows have identical elements in the first two columns, then you want to combine the two rows and just sum the third column? So the first two rows of A are
1.0000 2.5000 3.0000
1.0000 2.5000 4.0000
and this becomes
1.0000 2.5000 7.0000
Is that correct?

サインインしてコメントする。

回答 (1 件)

Sindhu Priya
Sindhu Priya 2017 年 2 月 14 日
You can try this SQL query to group the data
select column1,column2,sum(column3) as column3 from tablename group by column1,column2;
Regards,
Sindhu

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by