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 5955873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:10:33+00:00 2026-05-22T18:10:33+00:00

I have a problem with the following SQL SELECT c1.* FROM rmanager.requisitos_nao_funcionais c1 left

  • 0

I have a problem with the following SQL

SELECT c1.* FROM rmanager.requisitos_nao_funcionais c1 
left join rmanager.requisitos_nao_funcionais c2 
on c1.document_id = c2.document_id and c1.versao < c2.versao
where c1.id_projeto = 15 
and c1.id_req_fun = 5
and c2.document_id is null 
order by ordem ASC;

I’ve tried by a subselect also

SELECT *
FROM rmanager.requisitos_nao_funcionais A
WHERE versao = (
    SELECT MAX(versao)
    FROM rmanager.requisitos_nao_funcionais B
    WHERE B.document_id = A.document_id
)
and id_req_fun = 5
order by ordem asc;

but both returns me

return

it doesn’t get the document_id 1, it should return me 1,2,3 getting the lastest version of them

The table data is below

enter image description here

The SQL ideia is to get the lastest version of a document_id group(each document_id can has many versions) from a id_project and id_req_fun

I can’t find any problem.

  • 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-22T18:10:34+00:00Added an answer on May 22, 2026 at 6:10 pm
      SELECT c1.document_id, MAX(c1.version)
        FROM rmanager.requisitos_nao_funcionais as c1
       WHERE c1.id_projecto = 15
         AND c1.id_req_fun = 5
    GROUP BY c1.document_id
    

    I am not sure if i understood properly, but given a project and a req_fun this will give you the latest version for each document in the set.

    Now if you want the document (a single one) with the biggest version number try:

      SELECT c1.document_id, c1.version
        FROM rmanager.requisitos_nao_funcionais as c1
       WHERE c1.id_projecto = 15
         AND c1.id_req_fun = 5
    ORDER BY c1.version DESC
       LIMIT 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL query: SELECT Comment, JD, Jurisdiction, RegStatus, Region, SPDR_NAME FROM
I have a problem with the following Linq query using Entity Framework: from o
I need to do the following SQL with QueryOver in NHibernate: select * from
I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem using template instantiation [*]. file foo.h class Foo {
I have the following problem in my Data Structures and Problem Solving using Java
I have the following problem: I open the dialog, open the SIP keyboard to
I have the following problem. If I query values with a keyfigure which is
I have a problem with the following code: for(i = 0;(i - 1)< n;i++)

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.