我想顯示今年每月的總訪問量。但以下查詢返回缺少表達式的錯誤代碼。我錯過了什麼?顯示今年每月的訪問量
SELECT CASE
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 1 THEN 'January '
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 2 THEN 'February'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 3 THEN 'March'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 4 THEN 'April'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 5 THEN 'May'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 6 THEN 'June'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 7 THEN 'July'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 8 THEN 'August'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 9 THEN 'September'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 10 THEN 'October'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 11 THEN 'November'
ELSE 'December'
END AS "Month " ,
COUNT(*) AS "Number of visits"
FROM allrecord where extract(year from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy')= extract(year from date sysdate)
GROUP BY CASE
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 1 THEN 'January '
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 2 THEN 'February'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 3 THEN 'March'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 4 THEN 'April'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 5 THEN 'May'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 6 THEN 'June'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 7 THEN 'July'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 8 THEN 'August'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 9 THEN 'September'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 10 THEN 'October'
WHEN extract(month from date TO_DATE (TO_CHAR (visit_time, 'mm/dd/yyyy '), 'mm/dd/yyyy') = 11 THEN 'November'
ELSE 'December'
END;
問一個額外的問題,我正在使用ORacle應用程序構建器創建一個應用程序。但在創建頁面並想要編輯表單中的記錄後,會顯示一條錯誤消息,指出可以提取數據。這是什麼意思?我錯過了什麼步驟?
這是一個查詢? – 2012-02-15 08:37:41
我對Oracle的經驗幾乎沒有,但據我瞭解,您可以使用'TO_CHAR(visit_time,'MONTH')'而不是這個繁瑣的案例陳述? – GarethD 2012-02-15 08:47:49
對於Oracle Application Builder中的額外問題,您可能需要單獨提問,並提供有關您獲得的錯誤的更多詳細信息。 – 2012-02-15 09:25:14