| |
Welcome to the dBforums forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact support.
If you prefer not to see double-underlined words and corresponding ads, place your cursor here for ContentLink opt out.
|
 |

06-09-04, 15:26
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 20
|
|
|
Query help
|
I'm working on project that deals with upc numbers along with a quantity sold and retail numbers and such. My problem is that I have the same upc number on multiple times, I need these upc numbers to only appear once and have the other corresponding data to add up and appear on that same line.
Here is the code I am using:
PARAMETERS [Beginning Date] DateTime, [Ending Date] DateTime;
SELECT HIDATA60404.UPC, HIDATA60404.LONG_NAME, HIDATA60404.INV_SDESC, HIDATA60404.DEPARTMENT, HIDATA60404.CATEGORY, HIDATA60404.QSOLD, HIDATA60404.DSOLD, HIDATA60404.TOTALCOST, HIDATA60404.PROFIT, HIDATA60404.GPROFIT
FROM HIDATA60404
WHERE (((HIDATA60404.ELSDATE) Between [Beginning Date] And [Ending Date]) AND (([HIDATA60404]![ELSSTORE]) Like [store]) AND (([HIDATA60404]![CATEGORY])=[cat])) OR ((([store]) Is Null));
Thanks for any help you can provide.
|
|

06-09-04, 15:40
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,572
|
|
Are you looking for Sum() and GROUP BY ?
-PatP
|
|

06-09-04, 15:52
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 20
|
|
|
Honestly, I'm not sure where to go from here, It's been about 4-5 years since I've done any of this and I'm just trying to remember what I've done in the past. I thought it was somewhere along the lines of Select Distinct, but I have no clue if that's right.
|
|

06-09-04, 16:08
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,572
|
|
Can you post a sample that shows around a dozen rows of data, and the corresponding result set that you'd like to see?
-PatP
|
|

06-09-04, 16:33
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 20
|
|
Using the following code, I get 40 rows returned. Combining the results should make 17.
SELECT HIDATA60404.UPC, HIDATA60404.LONG_NAME, HIDATA60404.INV_SDESC, HIDATA60404.DEPARTMENT, HIDATA60404.CATEGORY, HIDATA60404.QSOLD, HIDATA60404.DSOLD, HIDATA60404.TOTALCOST, HIDATA60404.PROFIT, HIDATA60404.GPROFIT
FROM HIDATA60404
WHERE ((([HIDATA60404]![ELSSTORE])="10" And ([HIDATA60404]![ELSSTORE])="10") AND (([HIDATA60404]![CATEGORY])="141" And ([HIDATA60404]![CATEGORY])="141") AND ([HIDATA60404]![ELSDATE]>#5/23/2004# And [HIDATA60404]![ELSDATE]<#5/27/2004#));
I need the corresponding columns to total up with the single row i post.
|
|

06-09-04, 16:45
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,572
|
|
I can't find the results that you wanted to see, so this is just a guess, but I'm reasonably sure that you want to group by the first column, and Sum() the numeric columns.
-PatP
|
|

06-09-04, 17:14
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 20
|
|
I tried that. It groups the items together, but still shows up on multiple lines.
This is frustrating.
|
|

06-09-04, 17:26
|
|
Resident Curmudgeon
|
|
Join Date: Feb 2004
Location: In front of the computer
Posts: 9,572
|
|
If all you want is the "galactic total", just leave off the GROUP BY.
-PatP
|
|

06-10-04, 09:01
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 20
|
|
I did end up getting this to work. I had been trying that all day, Thanks for all your help.
Jeff
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|