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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:49:47+00:00 2026-06-13T11:49:47+00:00

For example, I have tab1: att1|att2 A|3 B|4 C|3 D|4 E|1 F|2 And I

  • 0

For example, I have

tab1:
att1|att2
A|3
B|4
C|3
D|4
E|1
F|2

And I want

B|4
D|4

I know I can use

SELECT att1 att2
FROM tab1 as T
WHERE T.att2 =
(
   SELECT MAX(att2) FROM tab1;
}

I wondering if there is a more clever way to do it. B/c if it takes a complicated query to get tab1, it is cumbersome to write it twice.
By the way, I am using Sqlite.

  • 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-13T11:49:47+00:00Added an answer on June 13, 2026 at 11:49 am

    My original answer was:

    SELECT att1, att2
    FROM tab1
    ORDER BY att2 DESC LIMIT 0,1;
    

    I apologize, that won’t work if there is more than one record with the max value. Here is another answer:

    SELECT t1.att1, t1.att2
    FROM tab1 AS t1
    LEFT JOIN tab1 AS t2
    ON t1.att2 < t2.att2
    WHERE t2.att1 IS NULL;
    

    It’s questionable whether this form is more efficient than nested SELECT the author mentioned, but might be better in case if tab1 is a select itself.

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

Sidebar

Related Questions

I have an oracle sql query select distinct tab1.col1, tab2.col1 from table1 tab1 join
Example: Here we have <p class=tab1 current></p> How can I get only the first
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
Example: I have an class that inherits from UIImageView. An object creates an instance
Example: I have a view controller and get rid of it. But there's still
(I have tightened up my original example) I'm trying to invoke modal dialogs from
Having a variable that can contain '#tab1'..'#tab4', How can I select and change the
I have 2 tabs , for example Tab1 & Tab2 which is displayed on
I have creating a learning application with play framework and i want to use
If I for example have <p> some long text </p> on my HTML page,

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.