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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:42:56+00:00 2026-06-13T15:42:56+00:00

I am having a problem with a select statement in MySQL. I have two

  • 0

I am having a problem with a select statement in MySQL.

I have two statements varying only slightly, the first appears to work but the second does not. The second statement returns 0 results. What am I missing/doing wrong?

Set Variables

SET @maxOK = 1.2;
SET @minOK = .8;

1# NOT BETWEEN

SELECT *, fee - (receipts * -1) AS difference
FROM div.Data1
WHERE (receipts * -1) NOT BETWEEN (fee * @minOK) AND (fee * @maxOkay);

2# BETWEEN

SELECT *, fee - (receipts * -1) AS difference,
          receipts * -1 as rec,
          fee * @minOk as min, fee * @maxOk as max
FROM div.Data1
WHERE (receipts * -1) BETWEEN (fee * @minOK) AND (fee * @maxOkay);

Some Data that should be showing in two but doesn’t

SELECT *, fee - (receipts * -1) AS difference,
          receipts * -1 as rec,
          fee * @minOk as min, fee * @maxOk as max
FROM div.Data1

enter image description here

  • 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-13T15:42:57+00:00Added an answer on June 13, 2026 at 3:42 pm

    You have an error in your statement. You have declared @maxOk but are using @maxOkay in your BETWEEN clause.

    As @maxOkayisn’t declared anywhere, it’s initialized to NULL so your statement essentially boils down to

    SET @maxOK = 1.2;
    SET @minOK = .8;
    
    SELECT *
           , fee - (receipts * -1) AS difference
           , receipts * -1 as rec
           , fee * @minOk as min
           , fee * @maxOk as max
    FROM Data1
    WHERE (receipts * -1) BETWEEN (fee * @minOK) AND NULL
    

    The statement should be

    SET @maxOK = 1.2;
    SET @minOK = .8;
    
    SELECT *
           , fee - (receipts * -1) AS difference
           , receipts * -1 as rec
           , fee * @minOk as min
           , fee * @maxOk as max
    FROM Data1
    WHERE (receipts * -1) BETWEEN (fee * @minOK) AND (fee * @maxOK);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problem with this statement declare @result int select @result = (select
I'm having a problem with my MySQL statement. I need a query that counts
I am having a problem inserting DATETIME into MySQL using PHP. First, I am
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I'm having problem with datagrid view. I have attached an image with the code
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
I am currently having a problem selecting a certain item from a mySQL database.
I'm having a rather strange problem with MySQL. Trying to create a procedure to
I am having problems loading the MySQL JDBC driver. I have tried everything mentioned
I'm trying to create a many-many statement but I am having problems with it.

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.