Hi
I am wondering about some results I am getting back when I am querying based
on date fields. I have a large table partitioned on source year. When I run
the following query the results are not correct results, it seems to be
grouping the year incorrectly.

select to_char(landed_dt,'YYYY'), count(distinct
vessel_code),sum(landed_value)
 from landing_hist
 where to_char(landed_dt, 'YYYY') in ('1994','1995','1996')
  and source_year in ('1994','1995','1996')
 group by to_char(landed_dt, 'YYYY')
 order by to_char(landed_dt, 'YYYY')

When I run the query for individual years the data returned is correct and
when I rewrite the query so that it is not being grouped by
to_char(landed_dt,'YYYY') (see below) the results are correct.

select source_year, count(distinct vessel_code),
   sum(landed_value)
 from landing_hist
 where to_char(landed_dt, 'YYYY') in ('1994','1995','1996')
  and source_year in ('1994','1995','1996')
 group by source_year
 order by source_year

Can anyone help me out with what I am missing - it seems like it has to be
something obvious - but I don't know what.

Thanks
Jane 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to