我编写了以下SQL查询来返回报告的一组结果。
然而,由于我缺乏知识,我正在努力使用where子句。我只需要查看建筑物所在建筑物的结果(BLDGCODE):
建筑物中的容量之和/建筑物中的占有率之和< 0.75
任何人都可以帮我完成这个吗?
SELECT
distinct (RTRIM(FME1.DESCRIP)) AS REGION,
RTRIM(FME2.DESCRIP) AS COUNTRY,
RTRIM(FMLS.SITEDESC) AS SITE,
RTRIM(FMB0.BLDGCODE) AS BLDGCODE,
rtrim(fmb0.bldgdesc) as BLDGDESC,
RTRIM(FMEZ.PROPTYPE) AS [PROPERTY TYPE],
rtrim(fma0.floorcode) as FLOORCODE,
(CASE WHEN FMA0.SPACETYPE = 'U-TLS-AS' OR
FMA0.SPACETYPE = 'U-VACU-AS' OR
FMA0.SPACETYPE = 'U-VACM-AS' THEN 0
ELSE FMA0.RENTABLE END) AS [CHARGEABLE AREA],
(CASE WHEN FMA0.SPACETYPE = 'U-TLS-AS' OR
FMA0.SPACETYPE = 'U-VACU-AS' OR
FMA0.SPACETYPE = 'U-VACM-AS' OR
FMA0.SPACETYPE = 'X-XXEXTW' OR
RTRIM(FMA0.SPACETYPE) like '%BC' OR
RTRIM(FMA0.SPACETYPE) like '%FC' OR
RTRIM(FMA0.SPACETYPE) like '%VP' THEN 0
ELSE FMA0.AREA END) AS [NET INT AREA],
(CASE WHEN FMA0.SPACETYPE = 'U-TLS-AS' OR
FMA0.SPACETYPE = 'U-VACU-AS' OR
FMA0.SPACETYPE = 'U-VACM-AS' OR
FMA0.SPACETYPE = 'X-XXEXTW' OR
FMA0.SPACETYPE like 'U-CAF%' OR
FMA0.SPACETYPE like 'U-FC%' OR
FMA0.SPACETYPE like 'U-LO%' OR
FMA0.SPACETYPE like 'U-MFR%' OR
FMA0.SPACETYPE like 'U-RANODSK%' OR
FMA0.SPACETYPE like 'U-SEC%' OR
FMA0.SPACETYPE like 'EQ-%' OR
RTRIM(FMA0.SPACETYPE) like '%BC' OR
RTRIM(FMA0.SPACETYPE) like '%FC' OR
RTRIM(FMA0.SPACETYPE) like '%VP' THEN 0
ELSE FMA0.AREA END) AS [FLOOR NET INT AREA],
ISNULL(rtrim(fmg0.group_),'0000') as [COST CODE],
isnull(RTRIM(FMG0.GROUPDESC),'Unassigned Space') AS [COST CENTRE],
(CASE WHEN FMA0.SPACETYPE like 'A-OFF-%' OR
FMA0.SPACETYPE like 'A-WKS-%' THEN FMA0.CAPACITY
ELSE 0 END) AS CAPACITY,
(CASE WHEN (FMA0.SPACETYPE like 'A-OFF-%' OR
FMA0.SPACETYPE like 'A-WKS-%') AND FMA0.CAPACITY = 1 AND FMA0.OCC_MAN > 0
THEN 1 ELSE 0 END) AS OCCUPANCY,
(CASE WHEN FMA0.SPACETYPE like 'A-OFF-%' OR
FMA0.SPACETYPE like 'A-WKS-%' THEN FMA0.OCC_MAN
ELSE 0 END)AS HEAD_COUNT,
fma0.spacetype as [SPACETYPE],
FMA0.RMID
FROM fmB0
LEFT JOIN FMLS ON FMB0.SITECODE = FMLS.SITECODE
LEFT JOIN FME2 ON FME2.CNTRY_CODE = FMLS.CNTRY_CODE
LEFT JOIN FME1 ON FME1.REG_CODE = FMB0.REG_CODE
LEFT JOIN FMA0 ON FMA0.BLDGCODE = FMB0.BLDGCODE
left join fmas on fma0.group_=fmas.group_
left join fmg0 on fma0.group_=fmg0.group_
left join fmez on fmb0.proptype=fmez.ez_key
where