Hello!
My knowledge of SQL is limited, so thanks for reading and hopefully responding to this simple question on DB2 for Windows.
I have a large warehouse table (3 mln rows with timestamps) and I need to select distinct values from a column (character type). A query SELECT (COLNAME) FROM TABNAME takes over (40 seconds). In these 3 mln rows, there are only 50 distinct values, and I'm only concerned with distinct values in the most recent (say 1000) rows. Unfortunately, a sorted query with an ORDER BY clause using FETCH FIRST N ROWS executes equally slow, probably because timestamp is written in a character column (another story).
What options do I have?
Thanks!
Sergei