Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can Count(), CASE(), and Distrinct be combined?
Message
 
 
À
28/01/2019 16:55:39
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01665760
Message ID:
01665777
Vues:
52
>>Hi,
>>
>>I am trying to count unique values in the field (using SQL Select) if the value is greater than 0
>>
>>So, here is syntax I use (simplified) (which generates an error):
>>
>>select count( case when mytable.myfield = 0 then 0 else distinct( mytable.myfield ) end ) as TotCount
>>
>>
>>What is wrong in the above syntax?
>>
>>TIA
>
>
select count( distinct  mytable.myfield ) as TotCount from myTable where mytable.myfield <> 0
The SQL Select must include all records, even those that have the value of mytable.myfield equal to 0 (zero). So I cannot use the WHERE as you suggested.
Please see Naomi's reply as the solution.
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform