SELECT MAX(TO_CHAR(DTM_LAST_MODIFIED,'MM/DD/YYYY')) As JobCompletionDate,
MAX(TO_CHAR(DTM_LAST_MODIFIED,'HH24:MI:SS')) As JobCompletionTime,
COUNT('Select * from wfimgr.device_usage where SERVICE_NAME in ("WIFILOC9","WIFIDEV9")') As SmartRouterSessions,
COUNT('Select * from wfimgr.device_usage where SERVICE_NAME NOT IN ("WIFILOC9","WIFIDEV9")') As NonSmartRouterSessions
FROM wfimgr.device_usage WHERE DTM_LAST_MODIFIED BETWEEN '28-MAR-2014' AND '29-MAR-2014'
答案 0 :(得分:2)
这可能会让你得到你想要的东西:
SELECT MAX(TO_CHAR(DTM_LAST_MODIFIED, 'MM/DD/YYYY')) As JobCompletionDate,
MAX(TO_CHAR(DTM_LAST_MODIFIED, 'HH24:MI:SS')) As JobCompletionTime,
sum(case when service_name in ('WIFILOC9','WIFIDEV9') then 1 else 0 end) as SmartRouterSessions
sum(case when service_name not in ('WIFILOC9','WIFIDEV9') then 1 else 0 end) as NonSmartRouterSessions
FROM wfimgr.device_usage
WHERE DTM_LAST_MODIFIED BETWEEN '28-MAR-2014' AND '29-MAR-2014'