Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can Count(), CASE(), and Distrinct be combined?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01665760
Message ID:
01665765
Views:
46
>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

Not sure I understood correctly, maybe you are looking for something like:
select (myField), COUNT(*) from myTable where myField <> 0 group by 1
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform