Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:47:09+00:00 2026-06-10T10:47:09+00:00

Using PL/SQL on Oracle 11g How can I write query to return desired result?

  • 0

Using PL/SQL on Oracle 11g How can I write query to return desired result? I want sum of detail using the expiry_date of Licenses table. All transactions in each group by must occur before the expiry_date.

Licenses

license_type vendor_code  funding_code  license_expiry_date 
---------------------------------------------------------------------------
CAB           1001        XR1           07/09/2011 4:23:18 pm
CAB           1002        XR2           07/06/2012 10:22:16 am

License_detail
register_period  license_type   active_date  fee  
---------------------------------------------------------------------
2012A            CAB             06/01/2011  25.00
2012A            CAB             07/01/2011  25.00
2012A            CAB             08/01/2011  30.00
2012A            CAB             09/01/2011  30.00
2012A            CAB             07/10/2012  40.00
2012A            CAB             07/11/2012  40.00

Desired Result

Period    Type   Funding   Vendor  TotalFees Expiry_Date
---------------------------------------------------------
2012A      CAB   XR1       1001     50.00    07/09/2011 4:23:18 pm
2012A      CAB   XR2       1002     60.00    07/06/2012 10:22:16 am
2012A      CAB   <null>    <null>   80.00    <null>        
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:47:10+00:00Added an answer on June 10, 2026 at 10:47 am

    What you need is an effective date and an end date for the licenses. You can then join this into the license detail, with something like this:

    select ld.period, ld.type, l.funding_code, l.vendor_code, sum(fee) as fee,
           l.license_expiry_date
    from license_detail ld left outer join
         (select l.*,
                 lead(license_expiry_date, 1) over (partition by license_type
                                                    order by license_expiry_date)
                                                   ) as nextdate
          from licenses l
         ) l
         on ld.license_type = l.license_type and
            ld.active_date >= coalesce(license_expiry_date, ld.active_date) and
            ld.active_date < coalesce(nextdate, to_date('9999-01-01', 'yyyy-mm-dd'))
    group by ld.period, ld.type, l.funding_code, l.vendor_code, l.license_expiry_date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using oracle 11g sql developer I have a varchar2 column with dates as
I'm using Oracle SQL Developer to query an Oracle DB (not sure which version
I'm using Squirrel SQL with Oracle. I often have to write quick queries for
I'm quite new to PL/SQL, and am using Oracle SQL Developer to write a
I am using Oracle 11g and Toad for Oracle. How can I display execution
I'm using Oracle 11g Standard Edition. I would like to log all SQL queries,
Oracle SQL can do hierarchical queries since v2, using their proprietary CONNECT BY syntax.
I want to extract text from a column using regular expressions in Oracle 11g.
Teaching myself SQL, and using an employee info db, on oracle 11g. I'm trying
I want to make Java code (using Oracle 11g and JDBC also) which will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.