sql - Macros in MySQL queries -
For the purposes of data analysis, I often do very similar questions where I am collecting data with different dimensions. Always use the change, but the field I am collecting is always the same. In practice, I am
key1, key2, ... sum (agg_field1), average (agg_field2), count (different agg_field3) ... to ... ... ou ... I have a lot of aggregation and if I can change the aggregation list by some kind of macros, then it will be a handful. I use the word "macro" because it Reminds me the C / C + macro I was imagining: select key 1, key 2, ..., from MY_AGGREGATIONS ... ou ... There will be a lot of benefits in it
- I will be more clear
- same adigrase
- It will be faster to write questions to other users
You can develop a task where you can pass the parameter and use the loop you can create, dynamically query if you want to execute that query , You can develop the store process where you dynamically ask You can prepare and execute it.
You can pass parameters with information such as how many consolidation fields you want, that you can use during the loop and create your query.
By creating a statement, you can execute dynamic queries
Comments
Post a Comment