Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subquery
Message
De
10/08/2016 03:47:12
 
 
À
10/08/2016 03:33:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01639295
Message ID:
01639301
Vues:
50
>Sir I do not know where I am using GROUP BY in both parts of the UNION in the inner subquery.
>
>Please modify.

Tariq, please go back and take a very close look at your original SQL code that you posted. It had two GROUP BY statements on the inside subquery. The more recent code that you posted did not.

Regardless, let's look at this code, that's part of the UNION, from your most recent post.


SELECT distinct(acc_code) as acc_code ,max(acc_name) as acc_name, qty, cr_amount
from crsalp where substring(acc_code,1,2)='32' and type='P'


You're asking for an aggregation (max) of the acc_name, and you're also specifying other columns (acc_code, qty, cr_amount). When you aggregate a column, and you specify other columns in the SELECT without aggregating on them, you need to specify a GROUP BY.

Now...if your query is going against FoxPro tables, you *might* want to try adjusting the ENGINEBEHAVIOR to tap into older Fox behavior for aggregations, though I generally think it's better to make the syntax work with propery aggregation rules.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform