473,554 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CrossTab Problems

4 New Member
Thank you, I'm making a little headway here as I can get the following code to return the first column for "ChartSales " correctly. Now I'm trying to add 2 more columns that sum different product sales.

The working portion of the code for 1 product is this so far. This gives the correct return.

Expand|Select|Wrap|Line Numbers
  1. SELECT sales_persons.Name, SUM(orders_table.Quantity) AS ChartSales
  2. INNER JOIN sales_persons
  3. ON sales_persons.PersonID = orders_table.PersonID
  4. WHERE orders_table.ProductID = 1
  5. GROUP BY sales_persons.Name
Now i'm trying to add the additional 2 more columns for the other products and mucking it up, I'm not exactly sure how to add the second or third where statement.

Expand|Select|Wrap|Line Numbers
  1. SELECT sales_persons.Name, SUM(orders_table.Quantity) AS ChartSales, SUM(orders_table.Quantity) AS GaugeSales, SUM(orders_table.Quantity) AS MAPSales
  2. FROM orders_table
  3. INNER JOIN sales_persons
  4. ON sales_persons.PersonID = orders_table.PersonID
  5. WHERE orders_table.ProductID = 1
  6.  
  7. ??????????????
  8. ON sales_persons.PersonID = orders_table.PersonID
  9. WHERE orders_table.ProductID = 2
  10.  
  11. ???????????????
  12. ON sales_persons.PersonID = orders_table.PersonID
  13. WHERE orders_table.ProductID = 3
  14.  
  15.  
  16. GROUP BY sales_persons.Name
**Admin Edit**
This question was posted as a response to a previous thread SQL Query Showing Total Sales by Each Person and Each Product.

This starts from a position where the following SQL is available as the source for a CrossTab :
Expand|Select|Wrap|Line Numbers
  1. SELECT   tSR.Name
  2.        , tSR.Region
  3.        , tP.Name
  4.        , SUM(tS.TotalSales) AS TotalProdSales
  5. FROM    ([Sales] AS tS INNER JOIN
  6.          [SalesRep] AS tSR
  7.   ON     tS.PersonNum = tSR.PersonNum) INNER JOIN
  8.          [Products] AS tP
  9.   ON     tS.ProductNum = tP.ProductNum
  10. GROUP BY tSR.Name
  11.        , tSR.Region
  12.        , tP.Name
Jul 31 '10 #1
5 1332
NeoPa
32,564 Recognized Expert Moderator MVP
This is tricky.

The first post made sense. I felt the second post also made sense, and provided a viable solution to the question posed in the first. The third post makes no sense to me whatsoever. It neither asks another question, nor in any way modifies the earlier question (not in any way I can see at least). It seems to be reflecting some sort of progression on unspecified areas of your project, but expressed in such a way that is not clear what you're trying to achieve even.

I can't see anything I can do to help except reflect back to you the situation as I see it and hope that you can somehow explain why the question isn't answered, or what you require further.
Aug 2 '10 #2
drgoodvibe
4 New Member
My apologies for making this overly complicated, what I'm trying to produce is the following chart. The code in post #3 gives me columns 1 and 2, I'm trying to add a 3rd and 4rth column that sums the Sales Person sales and groups it by product like in the 2nd column. however I can't seem to properly add the 3rd and 4rth columns.

Sales results by Sales Person by Product.
Expand|Select|Wrap|Line Numbers
  1. Sales_persons   Product1  Product2  Product3 
  2. SalesRep1        $400       $600     0
  3. SalesRep2        $700        0       $800
  4. SaleRep3          0         0        $1000
  5.  
Aug 2 '10 #3
NeoPa
32,564 Recognized Expert Moderator MVP
That makes some sense when considered in isolation, but you still give no relationship to this and the question that this thread is based on (Post #1).
Aug 2 '10 #4
drgoodvibe
4 New Member
Expand|Select|Wrap|Line Numbers
  1. SalesRep table
  2. ------------
  3. PersonName SalesPersonNumber
  4.  
  5.  
  6. SalesOrders table
  7. ----------
  8. SalesPersonNumber   Sales   ProductID
  9.  
The chart would sum the total sales of each Sales Person and show only their Person Name and the total Sales for that individual by ProductID as per the chart in #5

Thank you for your help in advance, this has been a great learning experience.
Aug 2 '10 #5
NeoPa
32,564 Recognized Expert Moderator MVP
I think I can sort of guess what you're talking about. The first question (the question for this thread) was about producing a dataset that could be used in the second question. The second question is quite a departure and needs to be split into a separate thread (I'll do that now for you).

The second question is about a cross-tab type query. I'm pretty inexperienced in such things so I'll simply point you in the direction and leave you to wait for some alternative help or play around with the query wizard and see what you can do for yourself with your new understanding.

Standard queries do not have columns based on the current data. This makes Cross-Tab queries somewhat different.
Aug 2 '10 #6

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

Similar topics

4
3924
by: Greg | last post by:
I am trying to set a perameter for my query but keep getting an error: The Microsoft Jet database engine does not reconize '' as a valid field name or expression. The only difference from other queries with the same parameter in my database is that this query is a crosstab. How do I fix this problem? Thanks, Greg
1
3330
by: Matthew Wells | last post by:
I have a crosstab query based on anothe query. The base query resultset has no null values in its "Quantity" column. However, when I create the new crosstab query from the base query, the records that should be 0 are blank. I trid the old IIF(IsNull(....etc but that didn't help. How do I make my blanks 0s? Thanks. Matthew Wells...
1
17647
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
4
8106
by: Judy | last post by:
I'm using Access 2003 and was wondering if it is possible to have a paramater selection within a crosstab query so that I wouldn't need to build a new table. I have a select query that I'm using to build the crosstab query from. In the select query I'm prompting for a specific quarter but when I go to run the crosstab it doesn't seem to...
6
4447
by: tizmagik | last post by:
I am having a lot of difficulty generating a CrossTab Query based report. I have looked online for several tutorials and whatnot but I have not been able to really find what I'm looking for, nor have I been able to adapt other people's solutions/tips to fit what I need. If anyone could please help me with the following it would be really...
27
18379
by: Bob | last post by:
running access 2k; mdb w/ linked tables to another mdb (front/back-end); trying to run a query that updates a table FROM information from a crosstab query. I AM NOTT trying to update the crosstab query itself - only use information FROM it to update a perfectly updatable table! Why the ---- would I get this error, when there are clearly...
1
1351
by: John | last post by:
Hi I have a report bound to a crosstab query. The problem is that under different conditions crosstab returns different column headings. This causes problems with binding of fields on report. Is there any way to make the column headings fixed in the crosstab query so the field names can be bound to report fields without problem? Thanks
4
2469
by: mattlightbourn | last post by:
Hi all, I have a problem which has been driving me nuts. Crosstab queries! I have a database witch a few different tables to do with garment manufacturing. I have a table for a client account, garment type (Jacket, skirt, etc), client sizing spec and descriptives (measurement names i.e: Shoulder to cuff, inside leg, etc), available...
3
3482
by: Niranjan | last post by:
I want create a report based on the crosstab query which normally returns about 50 - 60 columns. The columns have names of the counties and they keep changing for every session. Is there a way to program a dynamic multi-page crosstab report?
0
7611
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7812
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7894
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5162
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3579
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1145
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.