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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:18:32+00:00 2026-06-16T00:18:32+00:00

I’m a bit rusty with MySQL. I need some help figure out an order

  • 0

I’m a bit rusty with MySQL. I need some help figure out an order by.

I need it to be ordered by type, then by group with the highest group row date, and then each group ordered by date.
I need to make a query that will order a group rows by the highest date. I then need each group to be ordered by the highest date within that group. There is just one more thing. All rows a a type, but each group row has the same type.

Here is a visual representation of an unorganized table

| DATE | GROUP | TYPE |
-----------------------
| 2007 |     2 |    1 |
| 2008 |     3 |    2 |
| 2005 |     3 |    1 |
| 2004 |     2 |    1 |
| 2003 |     3 |    1 |
| 2012 |     3 |    2 |
| 2011 |     1 |    3 |

This organized:

| DATE | GROUP | TYPE |
-----------------------
| 2007 |     2 |    1 |
| 2004 |     2 |    1 |
| 2005 |     3 |    1 |
| 2003 |     3 |    1 |
| 2012 |     3 |    2 |
| 2008 |     3 |    2 |
| 2011 |     1 |    3 |

I’ve tried ordering it by type, group, than date, but this is inaccurate. I’m not entirely sure.

Here is a sample set of data:

| ID |               SET |             BLOCK | SHORTNAME | RELEASEDATE | SETTYPE |
----------------------------------------------------------------------------------
|  1 | Return to Ravnica | Return to Ravnica |       rtr |  2012-09-29 |       1 |
|  2 |         Gatecrash | Return to Ravnica |      NULL |  2013-02-01 |       1 |
|  3 |      Dragons Maze | Return to Ravnica |      NULL |  2013-05-03 |       1 |
|  4 |   Avacyn Restored |         Innistrad |       avr |  2012-05-04 |       1 |
|  5 |    Dark Ascension |         Innistrad |       dka |  2012-02-03 |       1 |
|  6 |         Innistrad |         Innistrad |       isd |  2011-09-30 |       1 |
|  7 |      New Phyrexia | Scars of Mirrodin |       nph |  2011-05-13 |       1 |
|  8 | Mirrodin Besieged | Scars of Mirrodin |       mbs |  2011-02-04 |       1 |
|  9 | Scars of Mirrodin | Scars of Mirrodin |       som |  2010-10-01 |       1 |

Group is block, type is settype, date is release date.

I need all block rows ordered by date within the block, each set of block rows ordered by highest date row within that block, and settype.

  • 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-16T00:18:32+00:00Added an answer on June 16, 2026 at 12:18 am

    Derive the row set of highest dates per block from your table, then join it back to your table to use the highest dates in the ORDER BY clause:

    SELECT
      t.*
    FROM atable t
    INNER JOIN (
      SELECT
        Block,
        MAX(ReleaseDate) AS HighestDate
      FROM atable
      GROUP BY Block
    ) s ON s.Block = t.Block
    ORDER BY
      s.HighestDate,
      t.SetType,
      t.Block,
      t.ReleaseDate
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.