从事务类型中选择从单列到多个的信用卡借记

时间:2016-12-09 09:14:22

标签: php mysql select

我有一张桌子

folders:  
    - map: ~/Code                     // this one
      to: /home/vagrant/Code
sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public       // and this one

我想要结果

id | amount | type 
1  | 2000   | cr
2  | 3000   | cr
3  | 4000   | dr

使用单个MySQL dr | cr 4000 | 5000 查询。

怎么做?

2 个答案:

答案 0 :(得分:0)

像这样:

select sum(amount) as amount, type from [your table] group by type

答案 1 :(得分:0)

    select (select count(amount) from table_name where type='dr') as dr,
 (select count(amount) from table_name where type='cr') as cr from table_name;

希望它有所帮助。 :)