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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:43:19+00:00 2026-06-04T13:43:19+00:00

How to view the first 2 rows in to single row Table1 id name

  • 0

How to view the first 2 rows in to single row

Table1

id  name     value size   result
----------------------------------
001 rajan    100   280DD   100%
002 Vijayan  200   120DD    80%
003 Sidarth  300   150DD    90%
004 Rakesh   400   270DD    95%
...

I want to select first 2 row in to single row….

Expected Output

id id name name value value size size result result
---------------------------------------------------------    
001 002 rajan vijayan 100 200 280DD 120DD 100% 80%
003 004 Sidarth Rakesh 300 400 150DD 270DD 90% 95%
.....

How to do this?

  • 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-04T13:43:20+00:00Added an answer on June 4, 2026 at 1:43 pm
    SELECT 
        t.Id, tt.Id, t.name, tt.name, t.value, tt.value, t.size, tt.size, t.result, tt.result
    FROM YourTable t
    INNER JOIN YourTable tt ON tt.Id = t.Id + 1
    WHERE tt.Id % 2 = 0
    

    That works for me. Hope it help you.

    Please try that if you stil need help.

    Declare @TempTable as table (FirstId int, SecondId int null, FirstCaption nvarchar(max), SecondCaption nvarchar(max) null, FirstDescription nvarchar(max), SecondDescription nvarchar(max) null)
    

    DECLARE @TempId int
    DECLARE curs CURSOR FOR
    SELECT ID FROM Categories
    open curs
    fetch next from curs into @TempId
    WHILE @@FETCH_STATUS = 0
    begin
    IF (@TempId % 2 = 1)
    BEGIN
    INSERT INTO @TempTable
    SELECT
    t.Id, null, t.Caption, null, t.Description, null
    FROM categories t
    WHERE t.Id = @TempId

        END
    ELSE
        BEGIN
            UPDATE @TempTable SET SecondId = t.Id, SecondCaption = t.Caption, SecondDescription = t.Description
            FROM categories t
            INNER JOIN @TempTable tt ON tt.FirstId = @TempId - 1
            WHERE t.Id = @TempId
        END
    fetch next from curs into @TempId
    

    end
    close curs
    deallocate curs

    SELECT * FROM @TempTable

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

Sidebar

Related Questions

I am working with an edit user view that includes First name, Last Name,
In the Model class I use return $query->row(); to return single rows and return
I have a two sections in my table view. First contains two rows, and
I have a project: first view is uitableview, when you select row uinavigationcontroller pushes
I googled around and learned that Lift encourages view-first development, lazy loading of entities,
in my application the first view is an UIView with a couple of uilabel
I have two views.In first view, I have a table view and I am
I have 2 views (first view - custom user control, MainWindow view - main
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
I have a UIViewController and I'm navigating from my first view controller to second

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.