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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:00:10+00:00 2026-05-12T15:00:10+00:00

If I have the following table: CREATE TABLE #temp ( id int, num int,

  • 0

If I have the following table:

CREATE TABLE #temp (
    id int,
    num int,
    question varchar(50),
    qversion int );

INSERT INTO #temp VALUES(1, 1, 'Question 1 v1', 1);
INSERT INTO #temp VALUES(2, 1, 'Question 1 v2', 2);
INSERT INTO #temp VALUES(3, 2, 'Question 2 v1', 1);
INSERT INTO #temp VALUES(4, 2, 'Question 2 v2', 2);
INSERT INTO #temp VALUES(5, 2, 'Question 2 v3', 3);
INSERT INTO #temp VALUES(6, 3, 'Question 3 v1', 1);

SELECT *
FROM #temp;

DROP TABLE #temp;

And I would like to get a table to display the three questions in their lastest version? This is in SQL Server 2005

  • 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-12T15:00:10+00:00Added an answer on May 12, 2026 at 3:00 pm
    CREATE TABLE #temp (
        id int,
        num int,
        question varchar(50),
        qversion int );
    
    INSERT INTO #temp VALUES(1, 1, 'Question 1 v1', 1);
    INSERT INTO #temp VALUES(2, 1, 'Question 1 v2', 2);
    INSERT INTO #temp VALUES(3, 2, 'Question 2 v1', 1);
    INSERT INTO #temp VALUES(4, 2, 'Question 2 v2', 2);
    INSERT INTO #temp VALUES(5, 2, 'Question 2 v3', 3);
    INSERT INTO #temp VALUES(6, 3, 'Question 3 v1', 1);
    
    WITH latest AS (
       SELECT num, MAX(qversion) AS qversion
       FROM #temp
       GROUP BY num
    )
    SELECT #temp.*
    FROM #temp
    INNER JOIN latest
        ON latest.num = #temp.num
        AND latest.qversion = #temp.qversion;
    
    DROP TABLE #temp;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following rows: CREATE TABLE #TEMP (id int, name varchar(255), startdate datetime,
I have the following table: CREATE TABLE TEST(ID TINYINT NULL, COL1 CHAR(1)) INSERT INTO
I have the following table and values: create table TreeTable ( ID int primary
I have the following procedure: CREATE PROCEDURE foo () SELECT * FROM fooBar INTO
I have the following Query: create table #Result (Reward varchar(40), Value MONEY); insert #Result
I have written a DB2 query to do the following: Create a temp table
I have the following table CREATE TABLE `prod_prices` ( `id` varchar(32) COLLATE utf8_unicode_ci NOT
I have the following table: create table ARDebitDetail(ID_ARDebitDetail int identity, ID_Hearing int, ID_AdvancedRatePlan int)
I have the following table: CREATE TABLE IF NOT EXISTS `customer_list` ( `id` INT
Let's say we have the following table: CREATE TABLE T ( ID INT, String1

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.