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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:24:25+00:00 2026-06-12T03:24:25+00:00

Image we have a table like this: table1 +———-+———-+——–+————+ | position | epoc |

  • 0

Image we have a table like this:

table1

+----------+----------+--------+------------+
| position | epoc     | name   | value      |
+----------+----------+--------+------------+
|    1     |    1     |   A    |        v01 |
|    1     |    1     |   B    |        v02 |
|    1     |    1     |   C    |        v03 |
|    1     |    2     |   A    |        v04 |
|    1     |    2     |   B    |        v05 |
|    1     |    2     |   C    |        v06 |
|    1     |    3     |   A    |        v07 |
|    1     |    3     |   B    |        v08 |
|    1     |    3     |   C    |        v09 |
|    1     |    4     |   A    |        v10 |
|    1     |    4     |   B    |        v11 |
|    1     |    4     |   C    |        v12 |
|    2     |    5     |   A    |        v13 |
|    2     |    5     |   B    |        v14 |
|    2     |    5     |   C    |        v15 |
|    2     |    6     |   A    |        v16 |
|    2     |    6     |   B    |        v17 |
|    2     |    6     |   C    |        v18 |
|    2     |    7     |   A    |        v19 |
|    2     |    7     |   B    |        v20 |
|    2     |    7     |   C    |        v21 |
|    2     |    8     |   A    |        v22 |
|    2     |    8     |   B    |        v23 |
|    2     |    8     |   C    |        v24 |
+----------+----------+--------+------------+

I want to be able to get this table:

table2

+----------+--------------------+
| position | value              |
+----------+--------------------+
|    1     |    v01,v02,v04,v05 |
|    2     |    v13,v14,v16,v17 | 
+----------+--------------------+

the conditions are:

  • JUST the “value” of rows with “name” A OR B;
  • JUST “epocs” that are the first 2 unique results in “position” (epoc 3,4,7,8 are discarded)
  • GROUP by table1 position (for each position I want the concat of the values that match previous conditions)
  • 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-12T03:24:26+00:00Added an answer on June 12, 2026 at 3:24 am

    This might be what you are looking for:

    select position, 
      group_concat(value order by overall_row_num) value
    from
    (
      select position,
          name,
          value,
          epoc,
           @num := if(@position = `position`, @num + 1, 1) as group_row_number,
           @position := `position` as dummy, 
          overall_row_num
      from
      (
        select position, name, 
          epoc, 
          value,
          @rn:=@rn+1 overall_row_num
        from t1, (SELECT @rn:=0) r
        where name in ('A', 'B')
        order by position, epoc
      ) x
      order by overall_row_num
    ) x1
    where group_row_number <= 4
    group by position
    

    See SQL Fiddle with demo

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

Sidebar

Related Questions

I have table like this ------------------------------------------------------------------- id | title | image | name |
I have a table layed out like this: <td> somename </td> <td class=hoverable value
please consider this image: I have a table like this: Age Active Men/Women -------------------------------------------------
i have a table company row like this : id(int) name(string) maincategory(int) subcategory(string) 1
I have a table column like this, where I want to align an image
I have a set of image paths stored in a table like this: +---------------------------------------------------------+
please consider this image: I have a table like this: Age Active Men/Women -------------------------------------------------
I have a table like this: Artist Image Title Smith 2 Country Smith 5
I would like to have a table header that looks like the image shown
In my database I have table AnimalDetails containing animalNumber(primary key),name,breed dateofbirth and an image

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.