locked
Fetch records from a table based on some condition. RRS feed

  • Question

  • User-526882573 posted

    Hai,

         I want to retrieve records from a table based on some conditions

    See this is my condition : Query to get sum of amount based on the year and transaction type.

    See below is my table:

    +-----------+-------------+
    | Field          | Type           
    +-----------+-------------+
    | tran_id      | int(5)           | 
    | cus_name | varchar(30)  | 
    | acc_no      | int(10)         | 
    | tran_date  | date            | 
    | amount     | int(6)          | 
    | tran_type  | varchar(20) | 
    | cus_id       | int(5)           | 
    +-----------+-------------+

    Please Help....

    Friday, October 17, 2014 1:29 PM

Answers

  • User-809753952 posted

    select sum(amount) from table_name group by year(tran_date), tran_type

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 17, 2014 1:37 PM

All replies

  • User-809753952 posted

    select sum(amount) from table_name group by year(tran_date), tran_type

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 17, 2014 1:37 PM
  • User-526882573 posted

    Thanks mnmhemaj....,

    Friday, October 17, 2014 10:40 PM