How to get the sum of of particular column using group by functionality while pulling data from sql using jdbc?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Geoff Hayes
el 9 de Feb. de 2017
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?
Respuestas (1)
Sindhu Priya
el 14 de Feb. de 2017
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
0 comentarios
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!