Solved

Oracle - max date filter issue

Posted on 2012-12-28
4
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

740 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