Can tables within the same schema become a filter?

jchan
New Member

There are many tables in our database having the same structure, and all of them need to add some customized measures.
 

For example, the tables named test1, test2, … test50.
These tables all have columns [ id, name, contract, earnings...] , and I need to create some frequently-used sql query as measures like [total_earnings, investment_count, ...] in each view.
 

However, it’s inefficient for me to keep adding identical dimensions/measures after the new table/view generated. I’ve tried using a parameter to filter different tables, so that I could use only one view:

derived_table: {
sql:
select * from schema.{% parameter tables %}
;;
}

parameter: tables {
type: string
}

But the variable `tables` return not found in the query, I’m wondering how could I modify this or maybe there’s a better approach?  

Many thanks!

0 3 125
3 REPLIES 3

Have you tried changing your parameter to type: unquoted?

jchan
New Member

@Dawid , thanks for your advice.

But changing to unquoted type seems not work in this case, if you have another workarounds please elaborate on that. Thanks a lot for help.

This wasn’t a workaround. When a paratmeter is a keyword like a field or table name, it has to be unquoted, otherwise, though depending on the dialect, you would have SELECT * FROM schema.”table” so for this to work it has to be unquoted. Based on what you provided, I don’t know where the problem might be

Top Labels in this Space
Top Solution Authors