Take this query:
SELECT EXTRACT(month FROM order_date) "Month"
FROM orders
(simplified example from official oracle doc)
How would you go at integrating such EXTRACT
operations above in a dbplyr
chain ?
I'm open to any other workaround (even ugly/costly) to extract the month on server side.
More elegant:
This results in the following SQL (ANSI SQL):
This trick works because the names of operators (what's between the percent signs) are literally translated to SQL.
NULL
disappears (unlikeNA
).Meanwhile I came up with something.
The expected output of given example will be obtained by executing this:
Here is the function's code, I included some parameters to force upper case columns (default) and to append new column to existing ones (default). Name of new column can be defined or by default will be named as the type of value you want to extract.