Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proper syntax with ODBC with sub select
Message
De
04/03/2006 18:00:31
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01101514
Message ID:
01101531
Vues:
10
>Try
>TEXT TO lcSql TEXTMERGE NOSHOW PRTEXT 15
>SELECT Country.Numero, Country.<<gcReturnTitle>> AS Title, COUNT(DISTINCT School.Numero)
>FROM FROM School
>JOIN Country ON School.NoCountry=Country.Numero
>WHERE School.Status=2
>ORDER BY 2
>ENDTEXT
>
I'm not sure what field you shoud use in COUNT(DISTINCT School.Numero) because I don't know youtr tables structure/relationship.
>Also notice how easier to maintain queries using TEXTMERGE.

The goal is to obtain the number of schools per country. So, I can then offer a listbox with 10 countries, for example, with the count of the number of schools in each. This is why I had the GROUP BY initially.

School.NoCountry is the key field we need to group on. So, I need to obtain the number of schools in each country. So far, I have this:
IF NOT loDMA.SQLExec('SELECT Country.Numero,Country.'+gcReturnTitle+' AS Title,COUNT(DISTINCT School.NoCountry) AS SchoolTotal FROM School '+;
 'JOIN Country ON School.NoCountry=Country.Numero '+;
 'WHERE School.Status=2 ORDER BY 2')
   RETURN loDMA.cHtml
ENDIF
This SQL now works. It does't give any error. But, I only get one record. I am not sure what I have to adjust to get what I am looking for.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform