'Using Loops in one Table through other Table
There are two Tables A & B.
Table A:

Table B

Now, the conventional and the messy SQL to get the desired output looks as follows:
select person, discount from a where Age >18 and category = 'Gold'
union all
select person, discount from a Age = 18 and category = 'General'
Table A includes multiple other characteristics/measures for person and is of 1 Million in rows.
Table B contains multiple rules for the discount calculation.
Currently, I am solving this through manually using the union all statement.
Please advice if any PL/SQL or stored proc may be using over Amazon Redshift to resolve the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
