Query not to show null fields (1 Viewer)

sibbbra

Member
Local time
Today, 23:20
Joined
Feb 11, 2022
Messages
78
hi,
I ahve a simple query:
1646393817238.png

I want that the order ID 144 and 145 should show only , with 1000 and 400 amount and the last 2 columns with null values to be dropped.
It should show as
1646394033879.png

the SQL is
SELECT Orders.Order_ID, Orders.Order_Date, Orders.Amount_Cash_Customer, Orders.Amount_Cash_Supplier
FROM Orders;
;;;;; please help, how to do that ;;;;;
 

Eugene-LS

Registered User.
Local time
Tomorrow, 02:20
Joined
Dec 7, 2018
Messages
481
I want that the order ID 144 and 145 should show only , with 1000 and 400 amount and the last 2 columns with null values to be dropped.
SQL:
SELECT Order_ID, Order_Date, Amount_Cash_Customer, Amount_Cash_Supplier
FROM Orders
WHERE
     (Amount_Cash_Customer = 1000)
     OR
     (Amount_Cash_Supplier = 400);
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 19:20
Joined
May 21, 2018
Messages
8,463
I want that the order ID 144 and 145 should show only , with 1000 and 400
Although @Eugene-LS solution is correct, I have to assume that is not really what you want. Seems pretty specific and not of much use.

Maybe you really are looking to return records where you have a value in either field greater than 0? FYI you do not have any Null values. You have values of 0. Very different.

Code:
WHERE Amount_Cash_Customer > 0 or Amount_Cash_Supplier > 0
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 07:20
Joined
May 7, 2009
Messages
19,169
should be OR:

SELECT Order_ID, Order_Date, Amount_Cash_Customer, Amount_Cash_Supplier
FROM Orders
WHERE
Amount_Cash_Customer <> 0
OR
Amount_Cash_Supplier <> 0;
 

sibbbra

Member
Local time
Today, 23:20
Joined
Feb 11, 2022
Messages
78
Although @Eugene-LS solution is correct, I have to assume that is not really what you want. Seems pretty specific and not of much use.

Maybe you really are looking to return records where you have a value in either field greater than 0? FYI you do not have any Null values. You have values of 0. Very different.

Code:
WHERE Amount_Cash_Customer > 0 or Amount_Cash_Supplier > 0
So kind of you. It helped
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 07:20
Joined
May 7, 2009
Messages
19,169
Why not, besides the logic?
i am sure he uses And not Or on the criteria (must be my eyes.. or his fast fingers)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 19:20
Joined
Feb 19, 2002
Messages
42,978
I did EXACTLY what TC asked (although there were doubts)
You read the first half of the question but not the second. The second half plus common sense would have suggested that you give some weight to your doubts.

You always have to read between the lines when answering questions and don't just blindly answer the specific question
 

Eugene-LS

Registered User.
Local time
Tomorrow, 02:20
Joined
Dec 7, 2018
Messages
481
You always have to read between the lines when answering questions
You are absolutely right.
Thank you so much for your kind advice and training.
I think you're being too kind to me.
 

Eugene-LS

Registered User.
Local time
Tomorrow, 02:20
Joined
Dec 7, 2018
Messages
481
Oh, I Understand now. Did not see the And only the Or.
I keep forgetting to write myself a poster:
"Before you turn on your computer - Don't forget to turn on your brain!" :)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 19:20
Joined
Feb 19, 2002
Messages
42,978
The desire to help lives within all of us who answer questions here:)
 

Eugene-LS

Registered User.
Local time
Tomorrow, 02:20
Joined
Dec 7, 2018
Messages
481
he desire to help lives within all of us who answer questions here
I agree with you again!
But there is also a "human factor" - because we are all human...
...
I think the "human factor" makes everything more interesting...
 

Users who are viewing this thread

Top Bottom