各位大侠帮小妹看看这个sql语句错在哪里,很急啊?
有表A, B,A中存放的是基本信息,B中存放的是数据,它们用编码连接也就是
(A.material_code = B.g_code)连接,现在我要取出B.g_tuinum的总数,B.loan的总数,以及B.g_tuinum每个记录的B.g_tuinum与之对应的单价想乘再求总金额,同样B.g_loan也以相同的方法求总金额,不晓得这个出错在哪里。
各位大侠帮忙指点一下。
select sum(B.g_tuinum) as totalin, sum(B.loan) as totalout, sum(A.material_price * B.g_tuinum) as totalinprice, sum(A.material_code * B.g_loan) as totaloutprice from tb_material A, "&tablename&" B where (A.material_code = B.g_code) and (B.g_date = '"&Sdate&"') and (B.g_tuinum > 0 or B.g_loan >0)