I have this query
SELECT Ets_Se_Categorie AS Ets_Se_Categorie,COUNT(Ets_Se_Categorie) AS cpte
FROM TableV_MyTest
GROUP BY Ets_Se_Categorie
It gives me the following table / results
Ets_Se_Categorie cpte
(Seems to be empty string) 5531
Old place 8
Secondary 1066
Principal 4713
Subsidiary 7985
First 9
headquarter 31610
Main Headquarter 1587
The (Seems to be empty string) means it is an empty field
Aim is to have this
Ets_Se_Categorie cpte
Old place 8
Secondary 1066
Principal 4713
Subsidiary 7985
First 9
headquarter 31610
Main Headquarter 1587
I've created this query
SELECT *
FROM
(
SELECT Ets_Se_Categorie AS Ets_Se_Categorie,COUNT(Ets_Se_Categorie) AS cpte
FROM TableV_MyTest
GROUP BY Ets_Se_Categorie
) AS A
WHERE (A.Ets_Se_Categorie IS NOT NULL OR A.Ets_Se_Categorie != '')
Issue is nothing has changed ...
Why did I use a nested query?
I tried this, first
SELECT Ets_Se_Categorie,COUNT(Ets_Se_Categorie) AS cpte
FROM TableV_MyTest
WHERE (Ets_Se_Categorie IS NOT NULL OR Ets_Se_Categorie != '')
GROUP BY Ets_Se_Categorie
Nothing happened...
Any insights would be greatly appreciated. Probably very simple but I'm bit confused on the why.
Thanks!
Ets_Se_Categorieis not an empty string, but instead whitespace? You could try trimming it -- something likewhere ltrim(rtrim(Ets_Se_Categorie)) != ''ANDits not''(i.e. change fromORto get what you want)ORinstead ofANDin your query to attempted.