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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:53:58+00:00 2026-05-16T15:53:58+00:00

I have a pretty simple table in SQLite, with the following schema: CREATE TABLE

  • 0

I have a pretty simple table in SQLite, with the following schema:

CREATE TABLE IF NOT EXISTS Palettes 
             (id INTEGER PRIMARY KEY AUTOINCREMENT, 
             class TEXT, count INTEGER, name TEXT);

These represent color palettes, and several palettes can have the same name, but different counts (i.e. sizes).

What I want to do is find, for each set of named palettes, the one having the greatest (or least) count.

My first thought was to start with:

SELECT * FROM Palettes GROUP BY name;

But, of course, which row I get is arbitrary. Looking further, it seems that even if I do:

SELECT MAX("count"), * FROM Palettes GROUP BY name;

I still get an arbitrary row.
One last shot:

SELECT * FROM (SELECT * FROM Palettes ORDER BY "count") GROUP BY name;

seems to work, but I cant find any guarantees anywhere.

Does someone have a solution to this problem? I can, of course, solve it in code, but I’d prefer an SQL solution, if possible.

Thanks,
-matt

  • 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-16T15:53:59+00:00Added an answer on May 16, 2026 at 3:53 pm

    This should do the trick:

    SELECT P.*
      FROM Palettes AS P JOIN
           (SELECT name, MAX("count") AS max_count
              FROM Palette
             GROUP BY Name) AS MC
           ON MC.Name = P.Name AND P."count" = MC.Max_Count;
    

    If there are several rows with the same maximum count for a particular name, you will get several rows returned.

    I’m using double quotes around “count” because it is, of course, also a keyword; the double quotes convert the name into a delimited identifier.

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

Sidebar

Related Questions

The table's schema is pretty simple. I have a child table that stores a
I have a pretty simple table with 5 columns: key, datetime, title, body, image
I have a pretty simple trigger: CREATE OR REPLACE FUNCTION f_log_datei() RETURNS TRIGGER AS
Facts I have a pretty simple table: ID, name, PARENT_ID I would like to
I have a pretty simple MySQL table with team names and id. Team names
I have a GWT CellTable - it's a pretty simple table with just a
I have a pretty simple mysql request, 1. request calls to table to get
I have a table that tracks emails sent. It is pretty simple. ID |
I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
i have pretty simple simple question (i hope so). How do i change the

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.