The MONTH function
The following query uses the MONTH function
to extract and show what month the customer call was received and
resolved, and it uses display labels for the resulting columns. However,
it does not make a distinction between years.
Figure 1. Query
SELECT customer_num,
MONTH (call_dtime) call_month,
MONTH (res_dtime) res_month
FROM cust_calls;
Figure 2. Query result
customer_num call_month res_month
106 6 6
110 7 7
119 7 7
121 7 7
127 7
116 11 11
116 12 12
The following query uses the MONTH function
plus DAY and CURRENT to show
what month the customer call was received and resolved if DAY is
earlier than the current day.
Figure 3. Query
SELECT customer_num,
MONTH (call_dtime) called,
MONTH (res_dtime) resolved
FROM cust_calls
WHERE DAY (res_dtime) < DAY (CURRENT);
Figure 4. Query
result
customer_num called resolved
106 6 6
119 7 7
121 7 7