一条单表统计的SQL语句

对SQL语句太欠缺,最近在做项目的统计功能,数据结构如下:

主键 收取币种 收取金额 支出币种 支出金额 插入时间
dealID currencyType amountIn currencyOut amountOut dateTime
1 USD 100 CNY 768 20100513
2 EUR 100 CNY 1200 20100513
3 USD 50 CNY 385 20100513
4 HKD 100 CNY 93 20100513

5 HKD 100 CNY 93 20100513

查询结果:根据时间查询出所有交易信息

     收取币种      收取金额总数  支出币种     支出金额总数
    currencyType  totalIn   currencyOut  totalOut   
      USD           150         CNY        1153
      EUR           100         CNY        1200
      HKD           200         CNY        186

各位SQL朋友帮忙看下了,先感谢下!

[code="sql"]SELECT
currencyType ,SUM(amountIn) AS totalIn , currencyOut SUM(amountOut) AS totalOut

FROM 你的表

WHERE datetime = 'XXXXXXXX'

GROUP BY currencyType[/code]

select * from table t where t.dateTime = ?

????是根据时间查取出所有交易信息么?

分组需要用 币种 吗?

[code="sql"]
select t.currencyType,
sum(t.amountIn) as totalIn ,
t.currencyOut,
sum(t.amountOut) as totalOut
from 你的表名 t
where t.dateTime >=开始时间 and t.dateTime <= 结束时间
group by t.currencyType,t.currencyOut
[/code]

[code="java"]select currencyType,currencyOut,sum(amountIn),sum(amountOut), from table t group by currencyType,currencyOut[/code]