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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:42:39+00:00 2026-06-11T14:42:39+00:00

This question is a continuation of Changing this query to group rows and filter

  • 0

This question is a continuation of Changing this query to group rows and filter out all rows apart from the one with smallest value but with an extra bit at the end….

I have the following results set:

275     72.87368055555555555555555555555555555556   foo    70
275     72.87390046296296296296296296296296296296   foo    90 
113     77.06431712962962962962962962962962962963   foo    80
113     77.07185185185185185185185185185185185185   foo    60 

that I got from this query:

SELECT id, (tbl2.date_modified - tbl1.date_submitted)/86400, some_value
FROM tbl1, tbl2, tbl3
WHERE tbl1.id = tbl2.fid 
AND tbl1.id = tbl3.fid

Notice there are 4 rows with 2 ids. I wanted to filter the rows to get only the minimum number in the second column. This fixed it:

SELECT id, min((tbl2.date_modified - tbl1.date_submitted)/86400), max(some_value)
FROM tbl1, tbl2, tbl3
WHERE tbl1.id = tbl2.fid 
AND tbl1.id = tbl3.fid
GROUP BY tbl1.id

so I got:

275     72.87368055555555555555555555555555555556   foo    70
113     77.06431712962962962962962962962962962963   foo    80

How can I change it to do the same but not include rows where the are other rows with some_value=90 ? I.e.

113     77.06431712962962962962962962962962962963   foo    80

I think I need some nested group or nested query ?!

Many thanks :).

  • 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-11T14:42:40+00:00Added an answer on June 11, 2026 at 2:42 pm

    You should be able to use NOT EXISTS:

    SELECT id, 
      min((tbl2.date_modified - tbl1.date_submitted)/86400), 
      max(some_value)
    FROM tbl1, tbl2, tbl3
    WHERE tbl1.id = tbl2.fid 
      AND tbl1.id = tbl3.fid
      AND NOT EXISTS (SELECT id 
                      FROM tbl2 
                      WHERE tbl1.id = tbl2.fid
                        AND some_value = 90)
    GROUP BY tbl1.id
    

    Or using ANSI join syntax:

    SELECT id, 
      min((tbl2.date_modified - tbl1.date_submitted)/86400), 
      max(some_value)
    FROM tbl1
    INNER JOIN tbl2
       ON tbl1.id = tbl2.fid 
    INNER JOIN tbl3
       ON tbl1.id = tbl3.fid
    WHERE NOT EXISTS (SELECT id 
                      FROM tbl2 
                      WHERE tbl1.id = tbl2.fid
                        AND some_value = 90)
    GROUP BY tbl1.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a continuation of this question from yesterday . Here are my three
Ok - this is in continuation from my earlier question about sending an email
This question is in continuation of this one . The deal is simple. Given:
This question is a continuation of my last one, regarding How to make Ruby
A continuation from this question I need a SQL statement that returns the number
Ok this is a continuation from this question: How to make a simple Hello
As a continuation in my thought patterns from this question: Saxon in Java: XSLT
This is a continuation question I had from a post yesterday: Initializing NSMutableDictionary (It's
This question is a continuation of this one but asking for a more specific
In a continuation from this question . I'm trying to bind a given function

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.