How to use values of columns as filters?

General
Visitor

How to use values of columns as filters?

Hi,

 

Do you konw how can I use the value of one column as a filter in a query?

 

Example:
Table1 STUDENTS : Contains students information
Table 2 PARSING: Contains filters to be applied to STUDENTS table

So in the PARSING table I have in one column all filters to be applied to the STUDENTS table for example:
PARSING.FILTER in one row contain as a value STUDENTS.NAME = 'JIM' AND STUDENTS.AGE = '20' AND STUDENTS.GRADE IN ('2', '3', '6')

How can I use the values of PARSING.FILTER as the filter for below query?
SELECT COUNT(*)
FROM 
STUDENTS
WHERE (USE THE VALUES OF PARSING.FILTER)

1 REPLY
Teradata Employee

Re: How to use values of columns as filters?

To use the value as part of the query text itself, you will need to write an application or stored procedure to dynamically construct the SQL string and then execute it.

It can also be done, e.g. via BTEQ, as a two-step process:

1) Combine the fixed part of the query with the PARSING table contents and export the full SQL statement(s)

2) Run the SQL resulting from step 1