473,466 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding to a query

76 New Member
I have a downloaded Access template I am trying to use. I am having a problem tying to add to the query. I am still learning so any help would be great. The SQL follows.

SELECT DISTINCTROW [Workorder Parts].WorkorderID, Sum([Quantity]*[UnitPrice]) AS [Parts Total]
FROM [Workorder Parts]
GROUP BY [Workorder Parts].WorkorderID;


I added a discount Field in a table, and a form to insert which parts I want to have the discount added to. Now I need to be able to subtract the percentage discount from the [Parts Total] Field and display it in the query. I then need to pull the query into the form where it shows the [Parts Total].

Thanks for your help in advance, and let me know if there is anything else you need.

Thanks,

Brian
Nov 20 '07 #1
8 1440
FishVal
2,653 Recognized Expert Specialist
Hi, Brian.

Please include the MetaData for all relevant datasets. Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Nov 20 '07 #2
Briansmi1116
76 New Member
Thanks for replying.
OK, I apologize for not having that info, I try to get the info you need.

Table name is Workorder Parts

Feild Name; Feild Type;

WorkorderPartID; AutoNumber;
WorkorderID; Number;
PartID; Number;
Quantity; Number;
Discount; Number;
UnitPrice; Currency;

I hope this helps.

Thanks,

Brian
Nov 20 '07 #3
FishVal
2,653 Recognized Expert Specialist
Well.

That seems to be simple.
Expand|Select|Wrap|Line Numbers
  1. SELECT [Workorder Parts].WorkorderID, Sum([Quantity]*[UnitPrice]*(1-[Discount]/100)) AS [Parts Total]
  2. FROM [Workorder Parts]
  3. GROUP BY [Workorder Parts].WorkorderID;
  4.  
The only question is why do you use DISTINCTROW predicate. Does you table contain fully duplicate records?
Nov 20 '07 #4
Briansmi1116
76 New Member
Yes the Workorder Parts Table has duplicate PartID's for the diffrent WorkorderID's. I didn't choose the idea, I just downloaded the template, and now I am trying to modify it to my use. So would I still need the distinctrow?
Nov 20 '07 #5
Briansmi1116
76 New Member
What I need to do is find the total price of parts, multiply it by the discount percentage, and subtract it from the total price of the parts. Does that make sense?
Nov 20 '07 #6
FishVal
2,653 Recognized Expert Specialist
What I need to do is find the total price of parts, multiply it by the discount percentage, and subtract it from the total price of the parts. Does that make sense?
So far you have discount value for each product and it is supposed that discount is for entire order. Am I right?
If so, then your table design is not suited for that.
Read Database Normalisation and Table structures article to get ideas on it.
Just for starters: you should have [tblOrders] and [tblOrderProducts] related one-to-many.

Yes the Workorder Parts Table has duplicate PartID's for the diffrent WorkorderID's. I didn't choose the idea, I just downloaded the template, and now I am trying to modify it to my use. So would I still need the distinctrow?
No. DISTINCTROW predicate allows to select from entirely unique records (eliminating records where all fields are the same). Read Access help on DISTINCT/DISTINCTROW predicates.
Nov 20 '07 #7
Briansmi1116
76 New Member
I think I found an alternate way. I have a form where it gives the amount due as a total. It gets information from three querys, and a table, for the form. I'm trying to get the discount percent added to this form, but I am unable to do so. I tried to change the control source to point at the feild, but it keeps showing "#Name?". What am i missing?
Nov 20 '07 #8
Briansmi1116
76 New Member
Never mind, I figured it out. Thanks again for your help.
Nov 20 '07 #9

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

Similar topics

4
by: Tryfon Gavriel | last post by:
Hi all I recently noticed when trying to optimise a major query of a chess website I am the webmaster of, that adding an order by for "gamenumber" which is a clustered index field as in for...
3
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have...
2
by: Viorel | last post by:
Adding new row with default values. In order to insert programmatically a new row into a database table, without direct "INSERT INTO" SQL statement, I use the well-known DataTable.NewRow,...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
4
by: John Siracusa | last post by:
I recently had a problem where a bunch of postgres backends were taking up huge amounts of CPU time. I found a bunch of log messages like this: NOTICE: adding missing FROM-clause entry for...
6
by: ljungers | last post by:
Hi to all and hope someone may have an answer for me. I have a Form named Cust_lukup_Form that has 3 text boxes and a click button that uses a OnClick to call Cust_lukup_Macro that runs an...
2
by: dympna | last post by:
Hi can anyone suggest a fix for this... as I am a novice in access. I have created a training table with the following fields Employee Name - joe Training Received - Fork lift Date Received...
0
by: uno7031 | last post by:
Help Please!!! Adding 5 Days to another Date in an access query Good Morning, Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.