在SQL项目中生成交叉表查询时可以控制空值显示为空白或0,
在ACCESS中如何实现?谢谢!
例如:
SQL项目:
空值显示空白:
SELECT TitleOfCourtesy,
SUM(CASE City WHEN 'London' THEN ReportsTo ELSE NULL END) AS [London City],
SUM(CASE City WHEN 'Redmond' THEN ReportsTo ELSE NULL END) AS [Redmond City],
SUM(CASE City WHEN 'Seattle' THEN ReportsTo ELSE NULL END) AS [Seattle City]
FROM Employees GROUP BY TitleOfCourtesy
空值显示为0:
SELECT TitleOfCourtesy,
SUM(CASE City WHEN 'London' THEN ReportsTo ELSE 0 END) AS [London City],
SUM(CASE City WHEN 'Redmond' THEN ReportsTo ELSE 0 END) AS [Redmond City],
SUM(CASE City WHEN 'Seattle' THEN ReportsTo ELSE 0 END) AS [Seattle City]
FROM Employees GROUP BY TitleOfCourtesy
————————————————————————————————————————
ACCESS:
空值显示空白:
TRANSFORM Sum(自动收款应收查询.月余额) AS 月余额之Sum
SELECT 自动收款应收查询.客户名称, Sum(自动收款应收查询.月余额) AS [总计 月余额]
FROM 自动收款应收查询
GROUP BY 自动收款应收查询.客户名称
PIVOT 自动收款应收查询.月份;
空值显示为0:
?
TRANSFORM IIf(IsNumeric(Sum([自动收款应收查询.月余额])),Sum([自动收款应收查询.月余额]),0) AS 月余额
SELECT 自动收款应收查询.客户名称, Sum(自动收款应收查询.月余额) AS [总计 月余额]
FROM 自动收款应收查询
GROUP BY 自动收款应收查询.客户名称
PIVOT 自动收款应收查询.月份; :)
[此贴子已经被作者于2005-3-14 14:05:15编辑过]
|