Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Per kg rate
Message
 
 
À
14/11/2016 03:10:32
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:
01643341
Message ID:
01643345
Vues:
47
I think you need:
select data1.month,sum(data1.qty) as qty,sum(data1.weight) as weight, sum(data1.amount) as amount,   
round(sum(amount)/iif(sum(weight)=0, null, sum(weight)),2)  as kgrt
	from
	(select	month(date) as month,qty,qty * weight as weight,cr_amount as amount from cashsalp
	where type='P' 
	union all
	select 	month(date) as month, qty,qty * weight as weight, cr_amount as amount from crsalp
	where type='P')
	as data1
	group by data1.month
It is always better to apply calculations at the very end to avoid problems with rounding and incorrect results.

>Dear..
>
>I am using this data
>
>
>select data1.month,sum(data1.qty) as qty,sum(data1.weight) as weight,sum(data1.amount) as amount,max(data1.kgrt)as kgrt
>	from
>	(select	month(date) as month,qty,qty * weight as weight,round(cr_amount/weight,2)as kgrt,cr_amount as amount from cashsalp
>	where type='P' 
>	union all
>	select 	month(date) as month, qty,qty * weight as weight,round(cr_amount/weight,2)as kgrt,cr_amount as amount from crsalp
>	where type='P')
>	as data1
>	group by data1.month
>
>
>In result, field kgrt is showing wrong data like
>
>144577602/4183502=34.55
>
>but is showing 40537.50
>
>Please help
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform