473,395 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem in query

274 100+
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
Dec 9 '07 #1
10 1415
9815402440
180 100+
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
Dec 9 '07 #2
creative1
274 100+
Still con't fix it. Please help me
Dec 10 '07 #3
Killer42
8,435 Expert 8TB
Still con't fix it. Please help me
I really think you'll get a better response on this in the Access forum. I'm going to move it over there.
Dec 10 '07 #4
QVeen72
1,445 Expert 1GB
Hi,

Try to Group by all the fields used in Select :

Expand|Select|Wrap|Line Numbers
  1. Group By control_info.gst, Group_codes.Group_ID, 
  2. Group_codes.Name
  3.  
Regards
Veena
Dec 10 '07 #5
Killer42
8,435 Expert 8TB
How are we doing on this - any progress?
Dec 12 '07 #6
creative1
274 100+
How are we doing on this - any progress?
I got this query fixed thanks for inquiring. But I had to add a new check with this query.
I am screwed up with a new check in the query thats is failing since last 24 hours.
I think I need help abt that. I'll post it today.
Dec 13 '07 #7
creative1
274 100+
Hi Expert,
Please help me correct this query. I can't get desired results.
Here's what I want to do for accounts's summary report.
here is my query that has no error but can't print what I want.

current GST rate is stored in table control_info(gst)
I want to calculate total of paid amount for group codes present in table .group_code , gst paid from table inv_details.

GST is paid only if following two are true.
for those products that have pay_gst= true in product_codes
vendors that have gst# in table Vendor(gst_no)

SELECT DISTINCT
control_info.gst, Group_codes.Group_ID, Group_codes.Name,
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, vendor
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 AND
control_info.status = true AND
product_codes.pay_gst = true AND vendor.gst_no <> NULL
GROUP BY Group_codes.Group_ID, Group_codes.Name,
control_info.gst, vendor.account_no


Problem: the query calculates total of all the transections and does not care about Vendor's gst_no. However pay_gst fields is kep in consideration.
Any help will be highly appreciated.
Dec 13 '07 #8
QVeen72
1,445 Expert 1GB
Hi,

Check this:

And (vendor.gst_no IS Not NULL And Trim(vendor.gst_no) <> '')

Regards
Veena
Dec 14 '07 #9
creative1
274 100+
no luck same result
I am worried
Dec 14 '07 #10
creative1
274 100+
Just to let you know, I fixed the problem; Don't ask HOW? ; )
Terrible experience.
Kind Regards
Dec 16 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
6
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
20
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
3
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows:...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.