怎麼樣寫這樣的sql語句,將符合某一條件的某些紀錄的某個字段(float型)的加和匯總;
adoquery2.SQL.Add('select SUM(數量*單價) 零件匯總 from partlist where 組件號=(select 組件號 from assemblylist where 組件名='''+wwDBLookupCombo7.Text+''')');哪位高手指點一下
adoquery2.SQL.Add('select SUM(數量*單價) 零件匯總 from partlist where 組件號=(select 組件號 from assemblylist where 組件名='''+wwDBLookupCombo7.Text+''')');哪位高手指點一下
from partlist as a,assemblylist as bwhere b.組件號=a.組件號
and b.組件名='''+wwDBLookupCombo7.Text+''''
from partlist as a,assemblylist as b where b.組件號=a.組件號
and b.組件名='''+wwDBLookupCombo7.Text+''') as 机器价格 from 组件表
from partlist as a,assemblylist as b where b.組件號=a.組件號
and b.組件名='''+wwDBLookupCombo7.Text+''') as 机器价格 from 组件表 where 机器号=当前机器号
from 零件表
where 组件号 in
(
select 组件号
from 组件表
where 设备号 in
(
select 设备号
from 设备表
where 设备名='XXXX'
)
)
给你一段我的统计汇总SQL参考
select top 10 chineseName, description, a.partno, amount, untprc
from
(select partno,amount=sum(poqty*untprc), untprc=sum(poqty*untprc)/sum(poqty)
from pur_podetal where complete=1
and (100*year('2002-10-8')+Month('2002-10-8')-(year(purdate)*100+month(purDate))=0)
group by partno) a inner join mat_partno pn(nolock)
on a.partno=pn.partno
order by amount desc
from partlist as a,assemblylist as b where b.組件號=a.組件號
and b.組件名='''+wwDBLookupCombo7.Text+''') as 机器价格 from 组件表 where 机器号=当前机器号
Sl是深麼意思???
Update assemblylist set assemblylist.組件費用 = a.組件費用 from (select SUM(數量*單價) as 組件費用,組件號 from partlist Group By 組件號) Where assemblylist.組件號 = a.組件號這是一個高手寫的.但運行的時候說'where'附近語法錯誤.