Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select GROUP field is empty or null
Message
De
22/03/2018 20:45:54
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01658951
Message ID:
01658955
Vues:
44
>>>Hi,
>>>
>>>I have the following SQL Select (simplified):
>>>
>>>
>>>cSqlselect = "SELECT " + cGroupField + " AS GROUP_ID " ....   GROUP BY " + cGroupField
>>>
>>>
>>>I want all records where the cGroupField is empty or NULL to be grouped into one record. But I get one row for all empty values and one row for all NULL values.
>>>
>>>How do you suggest I change the above SQL Select?
>>>
>>>TIA
>>
>>Dmitry
>>
>>Assuming you're working with MSSQL Server, use the ISNULL() function to transform NULL values into empty ones. For instance, for a column X with data type integer (null):
>>
>>
>>SELECT ISNULL(x, 0) FROM table_x GROUP BY ISNULL(x, 0);
>>
>
>Hi Antonio,
>I forgot that SQL Server has ISNULL() function (equivalent of NVL of VFP). This should work.
>Thank you very much!

Great!

For the record, NVL() is in use in ORACLE, too.
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform