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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:45:06+00:00 2026-05-13T20:45:06+00:00

I have a table Student , now I would like to query the result

  • 0

I have a table Student, now I would like to query the result the same as the second table. One group must have 2 students.

Student ID    Name    Gender    Group
1             A       M         A1
2             B       F         A1
3             C       M         A2
4             D       M         A2
5             E       F         A3
6             F       F         A3     
Name1    Gender1    Name2    Gender2    Group
A        M          B        F          A1
C        M          D        M          A2
E        F          F        F          A3
  • 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-13T20:45:07+00:00Added an answer on May 13, 2026 at 8:45 pm

    Here is the complete example.

    CREATE TABLE testing
    (id char(10),
    name char(10),
    gender char(1),
    grp char(10))
    
    insert into testing values ('1','A','M','A1')
    insert into testing values ('2','B','F','A1')
    insert into testing values ('3','C','M','A2')
    insert into testing values ('4','D','M','A2')
    insert into testing values ('5','E','F','A3')
    insert into testing values ('6','F','F','A3')
    
    
        select name1, gender1, name2, gender2, a.grp  from
        (
        SELECT name1 = CASE CONVERT(int,id)%2 WHEN 1 THEN name ELSE null END,
                gender1 = CASE CONVERT(int,id)%2 WHEN 1 THEN gender ELSE null END,
                grp FROM testing where CONVERT(int,id)%2 =1
        ) a 
        left join 
        (
        SELECT name2 = CASE CONVERT(int,id)%2 WHEN 0 THEN name ELSE null END,
                gender2 = CASE CONVERT(int,id)%2 WHEN 0 THEN gender ELSE null END,
                grp FROM testing where CONVERT(int,id)%2 =0
        ) b on a.grp=b.grp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table student ( id, name ). Then I have one textbox,
I have a table that includes some student group name, lesson time, day names
i have a table which consists of student details like roll no, Name, age.
I have Table Students with columns Student ID and Student Name. I also have
I have a table of student scores. Students can take the test multiple times,
I have a database table named 'student' in which there is one column named
I have two tables associated by FK. Table student is mapped like this: @Entity
I have three tables. The designs were like student table create table student (studID
I have a Student table which should have name column. But I made another
Friends, I have a dynamic sql query that I would like to execute and

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.