Supposing there are column names in the form of “event_i_j“ (“i“ and “j” represent numbers), such as “event_1_5“ and “event_5_1“. How to quickly select those with i > j?
Take the table t generated with the following script as an example:
t = table(1 2 3 4 as event_1_5, 1 3 4 5 as event_2_5, 1 2 3 4 as event_5_1, 1 2 3 4 as event_5_8, 1 2 3 4 as event_6_3)
How to select “event_5_1“ and “event_6_3“ from t?
You can use the
splitfunction to split each column name into “event“, “i“, and “j“. Compare “i“ and “j“ and select those with i > j. Here is an example SQL script generated with metaprogramming: