sql - MySQL - sum values to unique ids -


i have table file information, , query -- select distinct file, numbers table -- table create 2 column table name of file , numbers i.e.

    file |  numbers     ---------------        |    1        |    2        |    4     b    |    3     b    |    1     b    |    2     c    |    5     c    |    3     c    |    1 

i trying result, sum query unique file name i.e.

    file |  numbers     ---------------        |    7     b    |    6     c    |    9 

i can individual sum according file name via select file, sum(numbers) (select distinct file, numbers table) file = 'a'

but want have 3 present in results. have tried - select file, sum(numbers) (select distinct file, numbers table) result of

    file |  numbers     ---------------     c    |    22 

you need group by:

select `file`, sum(`numbers`) `tbl` group  `file` 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -