Avatar of Wilder1626
Wilder1626
Flag for Canada asked on

Oracle - filter sequal issue

Hello all

I have a problem with a SQL.

I have this SQL bellow that i use to pull resources from a table.

The thing is that in TL_RESOURCE_TRLR A i may have multiple A.TRLR_TYPE_ID based on A.EFFECTIVE

So i only want to extract the most updated effective date per TRLR_TYPE_ID and not all the effective dates even the old one. Just the very last one

How can i update this?

Thanks again for your help


  SELECT   DISTINCT A.CARRIER_ID,
                    A.EFFECTIVE,
                    A.TRLR_TYPE_ID,
                    A.CURRENT_NUM_VEHICLES
    FROM   TL_RESOURCE_TRLR A, CARRIER_EQUIP B
   WHERE       A.CARRIER_ID = B.CARRIER_ID(+)
           AND A.TRLR_TYPE_ID = B.TRLR_TYPE_ID(+)
           AND B.CARRIER_ID IS NULL -- EXCLUDE ROWS ADDED BECAUSE  OF THE OUTER JOIN
ORDER BY   A.CARRIER_ID ASC;

Open in new window

Oracle DatabaseSQL

Avatar of undefined
Last Comment
Wilder1626

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Wilder1626

ASKER
Hi slightwv

Let me look at this, i'm not having the same result in both SQL
slightwv (䄆 Netminder)

I might have fat-fingered when I retyped your SQL.

If you can provide some sample data and expected results, I can create an actual working example.
Wilder1626

ASKER
Hi again,

do you know what, i like the second one.

smaller but exactly what i need.

Thanks again for your help
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck