我正在从MSSQL数据库中获取一个列表。我有一个数据库表中的系统列表和材料。我想从日期范围中获得摘要。但数据库给我只有不是空的行。这里是我的代码SQL Group by不显示所有变量
select system_no AS 'SYSTEM NAME',
SUM(CASE WHEN (mat_2='AS') THEN mat_2_size END) as 'AS',
SUM(CASE WHEN (mat_2='SS') THEN mat_2_size END) as 'SS',
SUM(CASE WHEN (mat_2='CS') THEN mat_2_size END) as 'CS'
from fabrication_table
where welding_date between '2014-02-03' and '2014-02-09'
group by system_no
UNION
select 'TOTAL' as 'SYSTEM NAME',
SUM(CASE WHEN (mat_2='AS') THEN mat_2_size END) as 'AS',
SUM(CASE WHEN (mat_2='SS') THEN mat_2_size END) as 'SS',
SUM(CASE WHEN (mat_2='CS') THEN mat_2_size END) as 'CS'
from fabrication_table
where welding_date between '2014-02-03' and '2014-02-09'
这个查询的结果低于
SYSTEM NAME AS SS CS
Auxiliary steam NULL NULL 6.75
Chemical dosing NULL 10.00 NULL
Closed cooling water NULL 1.50 193.75
Condensate NULL NULL 32.00
Demineralized water NULL 34.00 NULL
Feedwater NULL NULL 6.00
Gases (N2, H2, CO2) NULL NULL 385.25
GT air intake anti-icing NULL NULL 220.50
Main steam & by-pass 49.50 NULL 84.00
Seawater intake NULL 27.50 NULL
ST drains 37.50 NULL 175.50
ST seals steam NULL 2.25 175.00
TOTAL 87.00 75.25 1278.75
但我的系统名单是:
Potable water Service water Seawater intake Chemical dosing Closed cooling water GT interconnections Feedwater HRSG blowdown Sampling Fire fighting GT Lube Oil Auxiliary steam Desalted water Demineralized water ST lube & seal oil Main steam & by-pass ST drains GT air intake anti-icing Condenser vacuum ST seals steam Condensate Plant drainage Filtered water Compressed air GT drainage Fuel gas Gases (N2, H2, CO2)
这里是我的问题:我想列出所有的变量,例如查询没有列出灭火,但我想列出消防这样
Fire Fighting NULL NULL NULL
i)在表格中手动检查“消防”,并验证每个选择的位置情况。 ii)删除工会,并使用工会全部 – KumarHarsh