Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Counter
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00410576
Message ID:
00410581
Views:
14
>I'm trying to increment a counter in a SQL statement based on a condition. I've seen the code before somewhere, but I can't find it. It's something like this:
>
>select max(iif(x>3,1,0),1) as counter ;
> from table1
>
>
You can run 2 selects:
select *, iif(x>3,1,0) as mCounter from table1 into cursor curTemp
select *, sum(mCounter) as finalCounter from curTemp group by somefield into table Table2

x should be Table1 field. AFAIK, you can not use aggregate function on functions, only on fields.

HTH
>
>This code isn't right, far from it, but there was someway to increment the "counter" that I can't remember. Does anyone have any idea what I'm talking about?
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform