tags:

views:

29

answers:

2

This is in teradata.

For many good reasons, I would like to have a something like the below, where I start by making a CTE that just has a list of literals, and then can refer to it in later statements:

with MyList(num) as(
    'a','b','c','d'
)

select foo from mytable where x in ( select(num) from MyList))

This is a very contrived example, and I know that it would have few applications in reality. But it does get at the question.

Thanks!

+1  A: 

Make a query that returns that result:

with MyList(num) as(
  select 'a' union all
  select 'b' union all
  select 'c' union all
  select 'd'
)
Guffa
A: 

Does teradata support Standard SQL row constructors?

WITH MyList (num) 
     AS
     (
      SELECT num
        FROM (
              VALUES ('a'),
                     ('b'),
                     ('c'),
                     ('d')
             ) AS MyList (num)
     ) 
SELECT num
  FROM MyList;
onedaywhen