>Hi all...
>Im trying to build a view to populate a grid with it.
>I need the view grouped by Names, and then COUNT certain values for each group of Names.
>
>Its a single table view. In the Functions and expressions field I try to enter this: COUNT all for status='Free'. When adding that expression to the fields list, VFP adds " " to the beginning and end of the expression.
>
>What is the correct way to add one or several Count for X='Y' expressions to a view in the view designer?
>TIA
> Ulises
Couple of things:
First and foremost:
You can't use the
COUNT
command in a view. You'd have to use the Count() aggregate function.
Is the count the only thing you want in there? If so, see below for my answer.
Second:
I would like to post a big message somewhere that all VFP developers can see that says
don't use the view designer < g > It sucks, plain and simple. or rather it's too basic...nah, it sucks.
eView in the files section here is good.
You
can do it in the view designer, but why?
It's just as easy to create one in code with
create sql view
.
e.g.,(you can do this right in the command window)
Open Database mydatabase
Create SQL View myview As Select Count(*) As statCount From mytable Where status='Free'
Or if you want a view that you can use for different statuses:
Open Database mydatabase
Create SQL View myview As Select Count(*) As statCount From mytable Where status=?vpcStatus
to use that one,
Open Database mydatabase
vpcStatus = 'Free'
Use myview
vpcStatus = 'Captured'
Requery("myview")
Insanity: Doing the same thing over and over and expecting different results.