Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subquery
Message
 
 
À
10/08/2016 03:50:14
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:
01639308
Vues:
83
This message has been marked as the solution to the initial question of the thread.
>Sir these codes have no error message but it is not performing group by acc_code
>
>
>text TO query TEXTMERGE noshow
>
>SELECT distinct(data.acc_code) as acc_code ,max(data.acc_name) as acc_name,
>sum(data.qty)as qty,
>sum(data.cr_amount)as c_ramount
>from (
>
>SELECT acc_code ,acc_name, qty, cr_amount
>	from crsalp where substring(acc_code,1,2)='32'  and type='P'
>
>union all
>
>SELECT acc_code ,acc_name, qty, cr_amount
>	from cashsalp where substring(acc_code,1,2)='31'  and type='P'
>) as data
>group by
>data.acc_code
>
>ENDTEXT
>
Try
text TO query TEXTMERGE noshow

SELECT acc_code, acc_name,
sum(data.qty) as qty,
sum(data.cr_amount) as cr_amount
from (

SELECT acc_code ,acc_name, qty, cr_amount
	from crsalp where acc_code like '32%'  and type='P'

union all

SELECT acc_code ,acc_name, qty, cr_amount
	from cashsalp where acc_code like '31%'  and type='P'
) as data
group by
acc_code, acc_name

ENDTEXT
Do you have multiple rows with the same code in your tables? From the first table you're taking accounts starting from 32 and from the second starting with 31. Also, I assumed that each acc_code has unique name.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform