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

  • Home
  • SEARCH
  • 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 7539941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:30:53+00:00 2026-05-30T07:30:53+00:00

I have the query below. SOFTWARE_DEVELOPMENT_CYCLE has multiple rows, but I’m interested in the

  • 0

I have the query below. SOFTWARE_DEVELOPMENT_CYCLE has multiple rows, but I’m interested in the latest.

I would like to rewrite the query so that I don’t use a subquery. I have attempted it with DENSE_RANK LAST ORDERY BY, but to no avail.

Could somebody advise? Thank you.

SELECT SOF.VENDOR, 
       SOF.NAME, 
       LAN.LANGUAGE, 
       SOF.VERSION, 
       SDC.STATUS, 
       SDC.SOF_DC_ID
  FROM SOFTWARE SOF
  JOIN SOFTWARE_LANGUAGES SL 
    ON (SL.SOF_SOF_ID = SOF.SOF_ID)
  JOIN LANGUAGES LAN 
    ON (SL.LAN_LAN_ID = LAN.LAN_ID)
  JOIN SOFTWARE_DEVELOPMENT_CYCLE SDC 
    ON (SDC.SOF_LAN_SOF_LAN_ID = SL.SOF_LAN_ID)
 WHERE SDC.SOF_DC_ID IN (SELECT MAX(SDC2.SOF_DC_ID)
                           FROM SOFTWARE_DEVELOPMENT_CYCLE SDC2
                          WHERE SDC2.SOF_LAN_SOF_LAN_ID = SL.SOF_LAN_ID)
 ORDER BY SOF.VENDOR, 
          SOF.NAME, 
          LAN.LANGUAGE, 
          SOF.VERSION;
  • 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-05-30T07:30:54+00:00Added an answer on May 30, 2026 at 7:30 am

    You could do something like this to avoid having to hit the SOFTWARE_DEVELOPMENT_CYCLE table a second time

    SELECT vendor,
           name,
           language,
           version,
           status,
           sof_dc_id
      FROM (SELECT SOF.VENDOR, 
                   SOF.NAME, 
                   LAN.LANGUAGE, 
                   SOF.VERSION, 
                   SDC.STATUS, 
                   SDC.SOF_DC_ID,
                   RANK() OVER (PARTITION BY sl.sdf_lan_id 
                                    ORDER BY sdc.sdf_dc_id DESC) rnk
              FROM SOFTWARE SOF
              JOIN SOFTWARE_LANGUAGES SL 
                ON (SL.SOF_SOF_ID = SOF.SOF_ID)
              JOIN LANGUAGES LAN 
                ON (SL.LAN_LAN_ID = LAN.LAN_ID)
              JOIN SOFTWARE_DEVELOPMENT_CYCLE SDC 
                ON (SDC.SOF_LAN_SOF_LAN_ID = SL.SOF_LAN_ID))
     WHERE rnk = 1
     ORDER BY VENDOR, 
              NAME, 
              LANGUAGE, 
              VERSION;
    

    The RANK analytic function is partitioning the result set by sl.sdf_lan_id. Then for each distinct sl.sdf_lan_id, it is assigning a numeric rank to the row based on the descending order of sdc.sdf_dc_id. That means that the row with the largest sdc.sdf_dc_id for a particular sl.sdf_lan_id will have a RANK of 1. The outer WHERE rnk=1 predicate then selects only the rows that have that maximum value. That should accomplish the same thing that your MAX subquery is accomplishing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query below that works but was wondering if there is a
I have a query (below) that takes forever to run when a customer has
I have a query below and would like to know if it is possible
I have a query like below declare @str_CustomerID int Insert into IMDECONP38.[Customer].dbo.CustomerMaster ( CustomerName
I have a query that returns a result set similar to the one below:
I have below a working query that needs to be simplified. The reason is
I have a query below that is returning individual sales records with amounts for
i have a query like below return this.Context.Modules .Select(p => new { Module =
I have the query below that fetches 500 records according to certain criteria. The
I have a MySQL query below that I'm using to get events for my

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.