Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can Count(), CASE(), and Distrinct be combined?
Message
De
29/01/2019 09:20:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/01/2019 08:35:55
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:
01665796
Vues:
49
>:) Read the original message (the very first one) again.

This is the original message as is:

"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?

Thanks in advance"

Thus the answer is:
select count(distinct mytable.myfield) as totCount from myTable where myTable.myfield <> 0
No need for case complexity.

Anyway, your question didn't in fact have relation to original question.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform