There is a table, and there are such columns in it:

price | trade_point_id | date 100 | 1 | 2019-01-01 112 | 1 | 2019-01-01 231 | 2 | 2019-01-02 180 | 2 | 2019-01-02 300 | 3 | 2019-01-03 10 | 3 | 2019-01-03 180 | 1 | 2019-01-04 800 | 1 | 2019-01-04 

I need to calculate the amount in the price column. So that those values ​​which have identical trade_point_id and date were summed up.

That is, the result table should be:

 sum | trade_point_id | date 210 | 1 | 2019-01-01 411 | 2 | 2019-01-02 310 | 3 | 2019-01-03 980 | 1 | 2019-01-04 

I do not understand what to write in WHERE.

  • Please indicate the SQL dialect used in the tags using the edit button - cpp questions
  • need grouping GROUP BY . SELECT SUM(price), trade_point_id, date FROM ТАБЛИЦА GROUP BY trade_point_id, date . in general, all aggregation functions require GROUP BY - Total Pusher
  • @cppquestions is similar to SQLite - Total Pusher
  • @TotalPusher hmm, how did you know that? In the question I see only the structure of the tables. Do you think dates are represented by strings? In any case, you can suggest an appropriate revision if the TC does not do it - cpp questions
  • Understood. Made using GORUP BY. SELECT SUM ( purchase . price ), purchase . trade_point_id , purchase . date FROM purchase GROUP BY purchase . date , purchase . trade_point_id ; Thank! - Svetlana

0