) = 'us' AND date_part('year', d.time) = 2004 GROUP BY mystate ORDER BY mystate;
Merlin Moncure <[EMAIL PROTECTED]> wrote:
Please post in plaintext, not html where possible.
Your group by clause was 'myst'...was that supposed to be mystate?
Yes, It is mystate. It continues on the next line:)
Her is something you might try...use the original query form and create a function which resolves the state code from the input data...you are already doing that with upper.
create function get_state_code(text) returns char(2) as
select case when len($1) = 2
language sql stable;
lookup_state_code is a similar function which is boils down to a select from a lookup table. Or, you could make a giant cast statement (when GEORGIA then GA, etc). and now your function becomes IMMUTABLE and should execute very fast. Just make sure all the states are spelled correct in the original table via domain constraint.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around