select device.USEUNIT, sum(
(select sum(czsp_table.quantity) CZSP from HG_DEVICEMANAGE czsp_table
where czsp_table.DEVICETYPE=24 and czsp_table.fd_objectid=device.fd_objectid)) czsp,
sum(
(select sum(tsdn_table.quantity) TSDN from HG_DEVICEMANAGE tsdn_table
where tsdn_table.DEVICETYPE=5 and tsdn_table.fd_objectid=device.fd_objectid)) tsdn,
sum(
(select sum(bjbdn_table.quantity) BJBDN from HG_DEVICEMANAGE bjbdn_table
where bjbdn_table.DEVICETYPE=6 and bjbdn_table.fd_objectid=device.fd_objectid)) bjbdn,
sum(
(select sum(sxj_table.quantity) SXJ from HG_DEVICEMANAGE sxj_table
where sxj_table.DEVICETYPE=1 and sxj_table.fd_objectid=device.fd_objectid)) sxj,
sum(
(select sum(zxj_table.quantity) ZXJ from HG_DEVICEMANAGE zxj_table
where (zxj_table.DEVICETYPE=3 or zxj_table.DEVICETYPE=2) and zxj_table.fd_objectid=device.fd_objectid)) zxj,
sum(
(select sum(jcsb_table.quantity) JCSB from HG_DEVICEMANAGE jcsb_table
where jcsb_table.DEVICETYPE=25 and jcsb_table.fd_objectid=device.fd_objectid)) jcsb,
sum(
(select sum(qtsb_table.quantity) QTSB from HG_DEVICEMANAGE qtsb_table
where qtsb_table.DEVICETYPE=23 and qtsb_table.fd_objectid=device.fd_objectid)) qtsb
from HG_DEVICEMANAGE device where device.IS_DEL='0' group by device.USEUNIT
(select sum(czsp_table.quantity) CZSP from HG_DEVICEMANAGE czsp_table
where czsp_table.DEVICETYPE=24 and czsp_table.fd_objectid=device.fd_objectid)) czsp,
sum(
(select sum(tsdn_table.quantity) TSDN from HG_DEVICEMANAGE tsdn_table
where tsdn_table.DEVICETYPE=5 and tsdn_table.fd_objectid=device.fd_objectid)) tsdn,
sum(
(select sum(bjbdn_table.quantity) BJBDN from HG_DEVICEMANAGE bjbdn_table
where bjbdn_table.DEVICETYPE=6 and bjbdn_table.fd_objectid=device.fd_objectid)) bjbdn,
sum(
(select sum(sxj_table.quantity) SXJ from HG_DEVICEMANAGE sxj_table
where sxj_table.DEVICETYPE=1 and sxj_table.fd_objectid=device.fd_objectid)) sxj,
sum(
(select sum(zxj_table.quantity) ZXJ from HG_DEVICEMANAGE zxj_table
where (zxj_table.DEVICETYPE=3 or zxj_table.DEVICETYPE=2) and zxj_table.fd_objectid=device.fd_objectid)) zxj,
sum(
(select sum(jcsb_table.quantity) JCSB from HG_DEVICEMANAGE jcsb_table
where jcsb_table.DEVICETYPE=25 and jcsb_table.fd_objectid=device.fd_objectid)) jcsb,
sum(
(select sum(qtsb_table.quantity) QTSB from HG_DEVICEMANAGE qtsb_table
where qtsb_table.DEVICETYPE=23 and qtsb_table.fd_objectid=device.fd_objectid)) qtsb
from HG_DEVICEMANAGE device where device.IS_DEL='0' group by device.USEUNIT