select A.TA014 as 日期,B.TB004 as 品号,B.TB005 as 品名,B.TB006 as 规格,sum(B.TB007) as 数量,sum(B.TB011) as 金额
from INVTA A,INVTB B where A.TA001=B.TB001 and A.TA002=B.TB002
and A.TA001 in ('1101','1103','1105','1106','1198') and A.TA014>='20120101'
and A.TA014<='20120831' group by B.TB004,B.TB005,B.TB006
上面这条语句 我怎么按日期分别统计出一月 到八月的数量和金额呢
from INVTA A,INVTB B where A.TA001=B.TB001 and A.TA002=B.TB002
and A.TA001 in ('1101','1103','1105','1106','1198') and A.TA014>='20120101'
and A.TA014<='20120831' group by B.TB004,B.TB005,B.TB006
上面这条语句 我怎么按日期分别统计出一月 到八月的数量和金额呢
from INVTA A,INVTB B where A.TA001=B.TB001 and A.TA002=B.TB002
and A.TA001 in ('1101','1103','1105','1106','1198') and A.TA014>='20120101'
and A.TA014<='20120831'
group by SUBSTRING(A.TA014,5,2), B.TB004,B.TB005,B.TB006
from INVTA A,INVTB B where A.TA001=B.TB001 and A.TA002=B.TB002
and A.TA001 in ('1101','1103','1105','1106','1198') and A.TA014>='20120101'
and A.TA014<='20120831'
group by SUBSTRING(A.TA014,5,2), B.TB004,B.TB005,B.TB006
from INVTA A,INVTB B where A.TA001=B.TB001 and A.TA002=B.TB002
and A.TA001 in ('1101','1103','1105','1106','1198') and A.TA014>='20120101'
and A.TA014<='20120831'
group by convert(varchar(8),A.TA014,120),B.TB004,B.TB005,B.TB006另外一个贴好像不少人回复,你先用你的数据测试下看看