I need to create a temp table with the data in table below in Netezza
. The typical way I would create a temp table in Netezza
is via
CREATE TEMP TABLE temp_table1 AS
(
-- statement to fill the data
) DISTRIBUTE ON RANDOM;
How do I go about constructing the statement to be used inside so that the data below is available in the temp table ?
+---------+----------+
| bin_val | bin_cnt |
+---------+----------+
| 0 | 2 |
| 4 | 10 |
| 8 | 15 |
| 12 | 12 |
| 16 | 6 |
| 20 | 1 |
+---------+----------+
A PostgreSQL
solution would also be helpful.
Is this what you want?
select v.*
from (values (0, 2), (4, 10), (8, 15), (12, 12), (16, 6), (20, 1)
) v(bin_val, bin_cnt)
Here is a SQL Fiddle.
This will probably not work in Netezza, because it uses a very old version of Postgres. Instead, I think you can do:
select 0 as bin_val, 2 as bin_cnt union all
select 4, 10 union all
select 8, 15 union all
select 12, 12 union all
select 16, 6 union all
select 20, 1