Solved

Oracle - max date filter issue

Posted on 2012-12-28
4
585 Views
Last Modified: 2013-01-10
Hello all

I have this query bellow that pulls the Max date.

But when i query, i dont get the max date.

  SELECT   DISTINCT A.CARRIER_ID,
                    MAX (A.EFFECTIVE),
                    A.TRLR_TYPE_ID,
                    A.CURRENT_NUM_VEHICLES,
                    L.NAME
    FROM   TL_RESOURCE_TRLR A, CARRIER_EQUIP B,LANE L
   WHERE   A.CARRIER_ID = B.CARRIER_ID(+)
           AND A.TRLR_TYPE_ID = B.TRLR_TYPE_ID(+)
           AND A.LANE_ID = L.ID
           AND B.CARRIER_ID IS NULL -- EXCLUDE ROWS ADDED BECAUSE  OF THE OUTER JOIN
GROUP BY   a.carrier_id, a.trlr_type_id, current_num_vehicles, L.NAME
ORDER BY   A.CARRIER_ID ASC;

Open in new window


Example:

From resources table:
date in date

From Query result:
Date in query result
How can i fix that please?

Thanks again for your help
0
Comment
Question by:Wilder1626
  • 2
4 Comments
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 250 total points
ID: 38727293
>>AND B.CARRIER_ID IS NULL -- EXCLUDE ROWS ADDED BECAUSE  OF THE OUTER JOIN<<
I'm not sure what your comment means in that you're trying to join on A.CARRIER_ID = B.CARRIER_ID. Could you provide some sample relevant data for the two tables and what you expect as results?
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 38727480
Oh sure.

Here you will see the resources extract and also the resources query result.

Thanks again
resources-TABLE.xls
resources-result.xls
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 250 total points
ID: 38730237
This query looks very strange to me.  You have a combination of "distinct" plus "max" on a.effective.  Are you sure that that will give you the result you want?  Then, you have an outer join, plus a "where" clause that restricts the rows to only those that are outer joined, but you have a comment that indicates you want the outer-joined rows to be excluded.
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 38765461
Hello guys,

Thanks for your help and sorry for the delay. I will work this out a little bit more.

markgeerm you are right.

I will re open another topic when i'm done thinking about all this.

Thanks again
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to recover a database from a user managed backup

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question