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 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 (a simplification of the real problem): SELECT * FROM
I have a problem creating the following SQL Statement using LINQ & C# select
I have the following SQL SELECT statement SELECT bar_id, bar_name, town_name, advert_text FROM bar,
I have the following SQL query: select expr1, operator, expr2, count(*) as c from
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
I have an SQL Function with the following SQL within: SELECT StockID FROM (SELECT
I have the following SQL query: SELECT Comment, JD, Jurisdiction, RegStatus, Region, SPDR_NAME FROM
I have to perform the following SQL query: select answer_nbr, count(distinct user_nbr) from tpoll_answer
I have a problem following from my previous problem . I also have the
I am using the following SQL query: Select * from table1 as t1, table2

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.