SELECTMONTH( a.paytime ) MONTH , b.qqnumber, SUM( a.amount ) amountFROM payment a, members b WHERE a.userid = b.userid ANDYEAR( a.paytime ) = ‘2012‘ GROUP BY b.qqnumber, MONTH
SELECTMONTH( p.paytime ) AS MONTH , SUM( p.amount ) AS amount, m.qqnumber AS qqnumber FROM Members mJOIN Payment p ON m.userid = p.userid WHERE YEAR( p.paytime ) =2012 GROUP BY m.qqnumber, MONTH