0

I am trying to solve a problem in Netezza for a friend of mine. My friend is trying to do something really simple in Netezza:

select * 
from 
test
where 
ID1 = 12345
and date >= 12/1/2012 and event date <= 12/31/2012
and ID2 in
(x1, x2, ..., x150000)

This query never returns.

In Oracle, we could have tried something like this:

/*******************************************************************/
/*To reduce the size of the table...*/

create table t_test as
select * 
from 
test
where 
ID1 = 12345
and date >= 12/1/2012 and event date <= 12/31/2012;

/*To make the search on ID2 faster...*/
create index i_ID2 on t_test (ID2);

select * 
from 
t_test
where 
ID2 in
(x1, x2, ..., x150000)

/*Alternative: People say "IN" may be very inefficient at times...*/

select * 
from 
t_test
where 
ID2 = x1
or ID2 = x2
.
.
.
or ID2 = x150000
/*******************************************************************/

However, this is not possible in Netezza, since it does not have any index concept.

How do I solve this problem?

Thanks and regards,

learning_spark
  • 669
  • 1
  • 8
  • 19

2 Answers2

2

Exactly how is the line "and date >= 12/1/2012 and event date <= 12/31/2012" coded when you run it? Do you really have a column named "DATE"? Is an underscore missing in "event date"?

12/1/2012 evaluates to integer zero, not a date. Use:

date '2012-12-01'
date '2012-12-31'

or to_date('12/1/2012', 'mm/dd/yyyy') like Oracle

redcayuga
  • 1,241
  • 6
  • 4
0

Try this way

select * 
from 
test
where 
ID1 = 12345
and eventdate BETWEEN DATE('12/1/2012') DATE('12/31/2012')
and ID2 in
(x1, x2, ..., x150000)
Nirav Mehta
  • 6,943
  • 9
  • 42
  • 51