As written:

CopySELECT CONCAT(area, yearlevel, code) AS SubjectCode, Count(student)
FROM StudentTakesSubject
WHERE result < 50 AND result <> NULL
GROUP BY code
HAVING Count(Student) > 1;

This query should return no rows. Why? result <> NULL returns NULL as a boolean value (to a close approximation all comparisons to NULL return NULL). AND NULL evaluates NULL -- and NULL is not true. All rows are filtered out.

The NULL comparison is actually superfluous. The result < 50 will also filter out NULL values.

Looking at the rest of the query, you have another issue. The GROUP BY is on code. It should really be on SubjectCode -- the result of the CONCAT(). In fact, when concatenating different columns, I would recommend using a separator, say CONCAT_WS(':', area, yearlevel, code). Of course a separator may not be desirable for this particular situation.

Answer from Gordon Linoff on Stack Overflow
🌐
Reddit
reddit.com › r/sql › question: is/is not null isn't working?
r/SQL on Reddit: Question: IS/IS NOT NULL isn't working?
June 10, 2019 -

I am working on a bunch of orders and I have an order date and the date that the order was "purchased". (The day we processed the order). If we never processed the order because the customer never followed through, there is a blank spot left in the purchased date resulting in a null when I run my query. I attempted to use IS NOT NULL to filter it out in the where statement but nothing happened. Any thoughts?

WHERE
DATE(a.ORDER_DATE) BETWEEN DATE(:startDate) AND DATE(:endDate)
AND
a.PURCH_ORDER_DATE IS NOT NULL;
Result of query

EDIT: For all of those who are wondering, I figured out how to sort out the null values.

SELECT DISTINCT
a.ORDER_NUMBER
,a.SALES_CATEGORY
,a.ORDER_DATE
,a.PURCH_ORDER_DATE
,CASE
    WHEN DATEDIFF(a.ORDER_DATE,a.PURCH_ORDER_DATE) >= 0 THEN DATEDIFF(a.ORDER_DATE,a.PURCH_ORDER_DATE)
    ELSE "null"
 END as Lag
FROM
SOBOOK a

WHERE
DATE(a.ORDER_DATE) BETWEEN DATE(:startDate) AND DATE(:endDate)
AND
ceil(DATEDIFF(a.ORDER_DATE,a.PURCH_ORDER_DATE)) = DATEDIFF(a.ORDER_DATE,a.PURCH_ORDER_DATE)

ORDER BY
 ORDER_NUMBER
,Lag
Discussions

query - Not equal to operator is not returning NULL values in SQL Server - Database Administrators Stack Exchange
Bring the best of human thought ... at your work. Explore Stack Internal ... I have the following query where I'm looking for any rows that are not equal to 1 for the column istrue. However, the results only include records with 0 and omit those with null. While I am aware that using (istrue != 1 or istrue is null) would yield the expected outcome, I am curious about the underlying mechanism causing SQL Server to ... More on dba.stackexchange.com
🌐 dba.stackexchange.com
ISNULL not working – SQLServerCentral Forums
Gail Shaw Microsoft Certified Master: ... Sci) SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability · We walk in the dark places no others will enter We stand on the bridge and no one may pass ... I hope it is not working because, alternateStudyCode and studyCode are nvarchar columns and ISNULL cannot be used on those. ... By not working, I assume that you get null value from ... More on sqlservercentral.com
🌐 sqlservercentral.com
November 19, 2013
"is not null" doesn't work | Access World Forums
Hi, I have a very simple query, ... it isn't working.... One column, and the criteria is "is not null". When run, the query still returns null values. The field is a look up field, but I don't know if matters or not.... Any thought? ... Please describe the lookup aspect? Also please post the query sql... More on access-programmers.co.uk
🌐 access-programmers.co.uk
August 19, 2011
How to see non null values?
I have a table which does not allow nulls in ColumnA. When I select * where ColumnA is not null, millions of rows are returned, most of them have no visible value . They may contain 1 or more spaces but how can I know for sure? Thanks, More on forums.sqlteam.com
🌐 forums.sqlteam.com
0
0
July 8, 2022
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 4785170 › query-with-is-not-null-criteria-not-working
Query with "Is Not Null" Criteria not Working - Microsoft Q&A
July 4, 2011 - My guess is that you had somehow set the database so that this field's Allow Zero Length string property (normally set to No) was set to Yes, and that you had "" - an empty string - in the field. This is not NULL and will fail these tests!
🌐
W3Schools
w3schools.com › sql › sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
SELECT column_names FROM table_name WHERE column_name IS NOT NULL; Below is a selection from the Customers table used in the examples: The IS NULL operator is used to test for empty values (NULL values). The following SQL lists all customers with a NULL value in the "Address" field:
🌐
DB Vis
dbvis.com › thetable › sql-is-not-null-condition-definitive-guide
SQL IS NOT NULL Condition: Definitive Guide
August 13, 2025 - IS NULL, as opposed to IS NOT NULL, is used to find records where a column explicitly contains a NULL value. In SQL, <> NULL and != NULL are equivalent, but neither works as expected because NULL represents an unknown value.
Find elsewhere
🌐
Mimo
mimo.org › glossary › sql › is-not-null
SQL IS NOT NULL Condition: Syntax, Usage, and Examples
Use IS NOT NULL to return rows where values are present and usable. Use SQL IS NOT NULL in a WHERE clause to filter out records that contain empty or missing values in a column.
🌐
Hightouch
hightouch.com › sql-dictionary › sql-is-not-null
SQL IS NOT NULL - Syntax, Use Cases, and Examples | Hightouch
December 29, 2023 - SELECT columns FROM table_name WHERE column_name IS NOT NULL; columns: The columns you want to retrieve in the query. table_name: The name of the table containing the data. column_name: The name of the column you want to filter based on whether ...
🌐
SQLServerCentral
sqlservercentral.com › home › topics › isnull not working
ISNULL not working – SQLServerCentral Forums
November 19, 2013 - When the record of the column is blank. How can I deal this? Couple options. You can combine NULLIF, which returns null if two expressions have the same value or you can use a case statement to check for empty string or null. ... SELECT CASE WHEN @SomeValue IS NULL OR @SomeValue = '' THEN 'The ...
🌐
Access World
access-programmers.co.uk › home › forums › microsoft access discussion › queries
"is not null" doesn't work | Access World Forums
August 19, 2011 - The criteria would not be Is Not Null but it would be <> 0 because the field is NUMERIC, and it has a default value set in the table as 0. AGAIN (and this is about the THIRD or fourth time I've told you this) - DO NOT USE LOOKUPS AT TABLE LEVEL!!!!
🌐
W3Schools
w3schools.com › mysql › mysql_null_values.asp
MySQL NULL Values - IS NULL and IS NOT NULL
SELECT column_names FROM table_name WHERE column_name IS NOT NULL; Below is a selection from the "Customers" table in the Northwind sample database: The IS NULL operator is used to test for empty values (NULL values). The following SQL lists all customers with a NULL value in the "Address" field:
🌐
Redgate Software
red-gate.com › home › redgate hub › product articles › sql prompt › the '= null' mistake and other sql null heresies
The '= NULL' Mistake and other SQL NULL Heresies
June 17, 2019 - SQL Prompt has a code analysis rule (BP011) that checks whether a comparison or expression includes a NULL literal ('NULL'). These will always produce a NULL result. To determine whether a datatype is, or isn't, NULL, use IS NULL or IS NOT NULL. Beyond that, working with a nullable datatype in an expression requires use of the COALESCE(), ISNULL() or NULLIF() functions, as appropriate, to deal with NULL values safely.
🌐
SQLTeam
forums.sqlteam.com › sql server administration
How to see non null values? - SQL Server Administration - SQLTeam.com Forums
July 8, 2022 - I have a table which does not allow nulls in ColumnA. When I select * where ColumnA is not null, millions of rows are returned, most of them have no visible value . They may contain 1 or more spaces but how can I know…
🌐
Reddit
reddit.com › r/sql › sql newbie question about not null
r/SQL on Reddit: SQL Newbie question about NOT NULL
March 26, 2024 -

Hi! Me and my sibling-in-law are just beggining to learn SQL and are about to get in a boot camp that gives you an introductory "exam". We failed it the first time, but weren't told why. This Exam willl change, so we're not looking to have our homework done so to say, we just want to understand what we did wrong in the first try.

And after watching a lot of videos and trying different solutions, we're a bit confused about this schema:

What we can't get a grasp on is what's the use of NOT NULL here? Like, how should we add that to our querys?

We're also a bit lost when it comes to item 10, how should we use "join" here?

Thank you in advance, we're doing our best!

I'll translate all the questions so that there's some context:

The first point was:

"Write an SQL query to show all the products in the table "Productos" with a price higher to $50."
Our answer was:

Select * from productos where Price > 50

Second point was:
"Write an SQL query to obtain the total amount of orders (pedidos) made by an specific client according to his ID"
Our answer was:

Select cliente_ID, count(*) as Pedidos_count
from Pedidos
where cliente_ID= ‘NOT NULL’
group by cliente_ID

Third point was:
"Write an SQL query to update the price of a product on the table "Productos""
Our answer was:

Update productos set price = ‘Float’
where nombre = ‘Varchar’

Fourth point was:
"Write an SQL query to show the names of the products together with their corresponding categories."
Our answer was:

Select nombre_varchar, categoria_varchar from productos

Fifth point was:
"Write an SQL query to delete all the orders that have an amount lesser than 5."
Our answer was:

Delete from pedidos where quantity < 5

Sixth point was:
"Write an SQL query to calculate the total price of the orders made."
Our answer was:

Select SUM (total_precio) as "total_pedidos_precio"
From Pedidos

Seventh point was:
"Write an SQL query to show the names of the products in ascendant alphabetical order."
Our answer was:

select * from productos
Order by nombre asc

Eighth point was:
"Write an SQL query to show the orders made in a specific date." (fecha means date).
Our answer was:

select * from Pedidos where date (fecha_pedido) = NOT NULL

Ninth point was:
"Write an SQL query to obtain the average of the prices of all the products."
Our answer was:

Select AVG (precio) from Productos

Tenth point was:
"Write an SQL query to show the products together with the total amount of orders made for each one."
We weren't sure about this one, we think we have to use the join clause, but we couldn't agree on how to.

Eleventh point was:
"What's the correct syntax to insert a new record in the table "Usuarios" (Users)"
a) INSERT INTO Usuarios (Nombre, Apellido) VALUES ('John', 'Doe'); (Picked this one)
b) INSERT Usuarios (Nombre, Apellido) VALUES ('John', 'Doe');
c) INSERT VALUES ('John', 'Doe') INTO Usuarios;
d) INSERT INTO Usuarios VALUES ('John', 'Doe');

Twelfth point was:
"What's the function used to obtain the total amount of records in a table?"
a) COUNT() (Picked this one)
b) SUM()
c) AVG()
d) MAX()

Thirteenth point was:
"What's the clause used to filter results in a SELECT query?"
a) WHERE (Picked this one)
b) FROM
c) ORDER BY
d) GROUP BY

Fourteenth point was:
"What's the operator used to combine conditions in a WHERE clause?"
a) OR
b) AND (Picked this one)
c) NOT
d) XOR

Fifteenth point was:
"What's the SQL query to delete an existing table?"
a) DELETE TABLE name_table; (Picked this one)
b) DROP name_table;
c) REMOVE name_table;
d) ERASE name_table;

Top answer
1 of 5
19
NOT NULL in the schema context means that the data in the table must contain a value for that column.
2 of 5
5
Hi, In general, NOT NULL in a column defintion, means that all rows must have a value in that column. Try looking into the following point: Point 1: The query looks correct Point 2: The idea looks correct, but the syntax looks is a bit off. As the cliente_ID is NOT NULL according to your diagram, you should not need to test that this is the case. In addition, the correct syntax would be "cliente_ID is NOT NULL" Point 3 : Perhap I am misunderstanding the wording, but this does not look correct. It looks like you have confused updating the datatype of the column with updating the value of a row in the table. It looks like you are trying to update the datatype while the question asks for updating the price value for a specific product. The query should be changed to have a number in "price =" and where statement should be change to use producto_id( In order to update the price for a specific product) Point 4 to 7: They look correct Point 8: Again, it seems like an misunderstanding regarding the NOT NULL constraint. The where statement should be changed to compare against a date. Again( As in Point 2), it should not be necessary to check for NOT NULL, as it is already a part of the table definition, that it is NOT NULL. Point 9: Look correct Point 10: You are correct you should use an join between the two tables. The arrow between the tables indicate which columns you should join on. Producto_ID is the Primary Key( The column which can be used to uniquely identify rows) in productos and it is a Foreign Key( A column that refers to a Primary Key in another table) in the Pedidos table. In order to join the together, you should therefore use Producto_ID in the On clause of your join Point 11 to Point 14: Look correct Point 15: There is a difference between DELETE and DROP. DELETE is used to delete rows in table( Se for example point 5 where you used DELETE along with a filer to remove specific orders). DROP, on the other hand, is used to delete the entire table. Hope that it helps you and gives you better understanding. Happy learning! :)
🌐
W3Schools
w3schools.com › sql › sql_notnull.asp
SQL NOT NULL Constraint
String Functions: Asc Chr Concat ... SQL Syllabus SQL Study Plan SQL Bootcamp SQL Training ... The NOT NULL constraint enforces a column to NOT accept NULL values....
🌐
MSSQLTips
mssqltips.com › home › sql where is not null examples
SQL WHERE IS NOT NULL Examples
March 13, 2023 - The basic SQL syntax for creating a sample database to work with: ... Run the script above to create a test database if you do not have one already. ... USE myTestDataBase; GO IF OBJECT_ID('MyEmployeeTable') IS NOT NULL DROP TABLE MyEmployeeTable; GO CREATE TABLE MyEmployeeTable ( colID INT IDENTITY NOT NULL, firstName VARCHAR(20), lastName VARCHAR(20), hireDate DATE, email VARCHAR(50), promote VARCHAR(10) ); GO
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-not-null-constraint
SQL NOT NULL Constraint - GeeksforGeeks
February 10, 2026 - In SQL, NOT NULL constraint in SQL ensures a column must always contain a value and cannot be left empty. Unlike a PRIMARY KEY, which uniquely identifies each record and also disallows NULLs, NOT NULL only enforces the presence of data without ...
🌐
Alma Better
almabetter.com › bytes › tutorials › sql › not-null-in-sql
NOT NULL in SQL
June 22, 2023 - It is important to note that NOT Null isn't a data type and can be utilized with any data type. To set a column to NOT Null in SQL, utilize the syntax Modify TABLE table_name Alter COLUMN column_name SET NOT Null.