查询中的问题 [英] Problem in query
问题描述
嗨专家
我再次需要你的帮助。
我使用此查询计算(价格*数量)的总和,并按主要类别代码对产品进行分组;即所有金属;非金属等
查询没有错误,但结果不正确。
它显示每个类别的总和和gst的两倍;当我打印结束摘要报告时,它会使所有类别的总价格翻倍。
这就是我所拥有的:粗体文字是有问题的区域。
SELECT control_info.gst,Group_codes.Group_ID,
Group_codes.Name,
SUM(inv_detail.price * inv_detail.quantity)AS price1,
SUM(inv_detail.price * inv_detail.quantity * control_info.gst)
AS gst1
来自product_codes,catagory_codes,inv_detail,inv_total,
Group_codes,control_info
WHERE group_codes.group_id = catagory_codes.group_id AND
product_codes.cat_code = catagory_codes.cat_code AND
product_codes。 Item_code = inv_detail.item_code AND
inv_detail.tran_id = inv_total.tran_id
GROUP BY Group_codes.Group_ID,Group_codes.Name,
control_info.gst
Hi Experts
I need your help once again.
I am using this query to calculate total of (price*quantity), and gst grouping the products by main category codes; i.e for all Metals; non metals etc.
Query has no error but the result isn''t correct.
It displays double of total and gst for each category; when I print closing summary reports it doubles the total price for all categories.
here is what I have: Text in bold is problematic area.
SELECT control_info.gst, Group_codes.Group_ID,
Group_codes.Name,
SUM(inv_detail.price * inv_detail.quantity) AS price1,
SUM(inv_detail.price * inv_detail.quantity * control_info.gst)
AS gst1
FROM product_codes, catagory_codes, inv_detail, inv_total,
Group_codes, control_info
WHERE group_codes.group_id = catagory_codes.group_id AND
product_codes.cat_code = catagory_codes.cat_code AND
product_codes.Item_code = inv_detail.item_code AND
inv_detail.tran_id = inv_total.tran_id
GROUP BY Group_codes.Group_ID, Group_codes.Name,
control_info.gst
推荐答案
hi
尝试相同的查询而不进行分组和求和。我认为字段inv_detail.price和inv_detail.quantity正在重复。 problam在于加入。纠正加入将解决问题。
问候
manpreet singh dhillon hoshiarpur
hi
try same query without grouping and summing. i think fields inv_detail.price and inv_detail.quantity are repeating themselves. problam lies in the join. correcting the join will solve the problam.
regards
manpreet singh dhillon hoshiarpur
仍然无法修复它。请帮帮我
Still con''t fix it. Please help me
仍然无法修复它。请帮我
Still con''t fix it. Please help me
我真的认为你会在Access论坛上得到更好的回复。我要把它移到那里。
I really think you''ll get a better response on this in the Access forum. I''m going to move it over there.
这篇关于查询中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!