Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with PostgreSQL Query
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01429771
Message ID:
01429791
Vues:
47
Thanks guys!
I'll test and see if the case when and charindex are accepted in postgre as well

Jaime

>>Dear all
>>I am trying to execute the following query in postgresql, but keep getting errors ("error near group by"). Tried to run it in pgadmin's query tool, and got different errors ( like IIF not recognized ). Can anyone help me "translate" the sql from vfp to postgre?
>>Table name in postgre: weblog
>>Fields: agent C(4), function varchar(20), xmlstr text
>>
>>lcStr = [select weblog.agent, ]+;
>>[sum(iif(weblog.function="GetCars" or "GETCARS"$weblog.xmlstr,1,0)) as RateRequests,]+;
>>[sum(iif(weblog.function="CarRes" or "CARRES"$weblog.xmlstr,1,0)) as Bookings ]+;
>>[from weblog order by weblog.agent group by weblog.agent]
>>=sqlexec( oConnection,  lcStr, "TempCursor" )
>>
>>TIA
>>Jaime
>
>Don't know if the SQL Server T-SQL syntax has something common with postgre, but here the SQL Server version:
>
>TEXT TO lcStr NOSHOW
>     select weblog.agent,
>            SUM(CASE WHEN weblog.function = 'GetCars' OR
>                         CHARINDEX('GETCARS', weblog.xmlstr) > 0
>                     THEN 1 
>                     ELSE 0 END) as RateRequests,
>            SUM(CASE WHEN weblog.function = 'CarRes' OR
>                         CHARINDEX('CarRes', weblog.xmlstr) > 0
>                     THEN 1 
>                     ELSE 0 END) as Bookings
>     from weblog
>     group by weblog.agent --- Group must be before ORDER BY
>     order by weblog.agent
>ENDTEXT
>
Why do programs stop working correctly as soon as you leave the Fox?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform