** Admin Edit **
This thread has been split off from the original ( Query/subquery - percentage).
** /Admin Edit **
Seeing as it appears we are coming to the end of this problem, i would like to present you with another one that perhaps will only take a little thought on your half.
Im creating a cross tab query which sorts via [SteveCode] and sums the [Tonnage] for each type of [RecyType]. I want to be able to add a date criteria, so the user can specify that the query processes data between two dates.
I have looked long and hard on the net for any answers and it seems that this has appeared often but without a proper solution. I offer the following SQL of my query: - PARAMETERS [Forms]![Recycling Rates]![From Date] DateTime, [Forms]![Recycling Rates]![To Date] DateTime;
-
TRANSFORM Sum(Tonnage.Tonnage) AS SumOfTonnage
-
SELECT Tonnage.SteveCode
-
FROM Tonnage
-
WHERE (((Tonnage.SteveCode) Is Not Null) AND ((Tonnage.RecyType)="Dry (Recyclable)" Or (Tonnage.RecyType)="Green (Recyclable)" Or (Tonnage.RecyType)="Glass (Recyclable)" Or (Tonnage.RecyType)="Food (Recyclable)" Or (Tonnage.RecyType)="Residual") AND ((Tonnage.Date) Between [Forms]![Recycling Rates]![From Date] And [Forms]![Recycling Rates]![To Date]))
-
GROUP BY Tonnage.SteveCode
-
PIVOT Tonnage.RecyType;
If i change the two date parameters, the same results will show so it obviously is not working.
Any ideas?
10 1943 NeoPa 32,556
Expert Mod 16PB
Seeing as it appears we are coming to the end of this problem, i would like to present you with another one that perhaps will only take a little thought on your half.
Im creating a cross tab query which sorts via [SteveCode] and sums the [Tonnage] for each type of [RecyType]. I want to be able to add a date criteria, so the user can specify that the query processes data between two dates.
I have looked long and hard on the net for any answers and it seems that this has appeared often but without a proper solution. I offer the following SQL of my query: - PARAMETERS [Forms]![Recycling Rates]![From Date] DateTime, [Forms]![Recycling Rates]![To Date] DateTime;
-
TRANSFORM Sum(Tonnage.Tonnage) AS SumOfTonnage
-
SELECT Tonnage.SteveCode
-
FROM Tonnage
-
WHERE (((Tonnage.SteveCode) Is Not Null) AND ((Tonnage.RecyType)="Dry (Recyclable)" Or (Tonnage.RecyType)="Green (Recyclable)" Or (Tonnage.RecyType)="Glass (Recyclable)" Or (Tonnage.RecyType)="Food (Recyclable)" Or (Tonnage.RecyType)="Residual") AND ((Tonnage.Date) Between [Forms]![Recycling Rates]![From Date] And [Forms]![Recycling Rates]![To Date]))
-
GROUP BY Tonnage.SteveCode
-
PIVOT Tonnage.RecyType;
If i change the two date parameters, the same results will show so it obviously is not working.
Any ideas?
I will have a quick stab at this, but if that doesn't resolve it, please post this as a separate question. You may post a link to your new thread in here if you will, but threads work a lot better if they stay on track.
Anyway, I think your ANDs and ORs might be the problem here. That is to say, I couldn't find an actual problem, but simplifying may help. Try this SQL anyway : - PARAMETERS [Forms]![Recycling Rates]![From Date] DateTime,
-
[Forms]![Recycling Rates]![To Date] DateTime;
-
-
TRANSFORM Sum(Tonnage) AS SumOfTonnage
-
-
SELECT SteveCode
-
-
FROM Tonnage
-
-
WHERE (([SteveCode] Is Not Null)
-
AND ([RecyType] In('Dry (Recyclable)',
-
'Green (Recyclable)',
-
'Glass (Recyclable)',
-
'Food (Recyclable)',
-
'Residual'))
-
AND ([Date] Between [Forms]![Recycling Rates]![From Date]
-
And [Forms]![Recycling Rates]![To Date]))
-
-
GROUP BY SteveCode
-
-
PIVOT RecyType;
Last post then, if this doesnt solve then i will start a new thread.
Ive tried that SQL and there was a missing operator error message. my knowledge of SQL is very limited so i cannot solve this.
NeoPa 32,556
Expert Mod 16PB
My knowledge of Cross-Tab queries (PIVOT) is also limited, but if you post the whole error message then I'll see what I can do.
Posting a new thread might have garnered some new, more appropriate, expert interest.
Syntax error (missing operator) is query expression
(([SteveCode] Is Not Null)
AND ([RecyType] In('Dry (Recyclable)',
'Green (Recyclable)',
'Glass (Recyclable)',
'Food (Recyclable)',
'Residual')
AND ([Date]
NeoPa 32,556
Expert Mod 16PB
There should have been two ")"s after 'Residual' (My posted SQL was in error). You appreciate I'm not in a good position to test this, so I just have to be as careful as I can, working it out in my head.
I have now fixed this in post #3 so you can copy / paste it again and it should work.
Error messages can be quite helpful really ;)
brilliant. Right thats the last of that for me then. Just had to finish a few things off before i leave Friday for university and a completely different carrer path.
Thanks for your help.
NeoPa 32,556
Expert Mod 16PB
Very pleased that's working for you now.
For interest, which Uni are you off to and what are you studying?
NeoPa 32,556
Expert Mod 16PB
I've just come across a further two threads posted yesterday which both appear to have been asking the same question (as this). This is not acceptable (see the rules) as it wastes lots of time. I have removed them both.
There should have been two ")"s after 'Residual' (My posted SQL was in error). You appreciate I'm not in a good position to test this, so I just have to be as careful as I can, working it out in my head.
I have now fixed this in post #3 so you can copy / paste it again and it should work.
Error messages can be quite helpful really ;)
Stewart, just lookin out. Neo, Sorry, I couldn't resist. :P
"You just can't get the staff nowadays :D"
NeoPa 32,556
Expert Mod 16PB Sign in to post your reply or Sign up for a free account.
Similar topics
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Jeff Rodriguez |
last post by:
Here's what I want do:
Have a main daemon which starts up several threads in a Boss-Queue structure.
From those threads, I want them all to sit and watch a queue. Once an entry
goes into the...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: jlamanna |
last post by:
I was wondering if there was a utility that could tell you when your C#
application is making cross-apartment COM calls. I have a fairly large
application that makes extensive use of a 3rd party...
|
by: aspmonger |
last post by:
Hello,
I really believe that IE 6 has a new (intentional?) bug that severely limits the capability of dhtml and cross domain scripting. Yesterday, I read an interesting article about the subject and...
|
by: Robert Bravery |
last post by:
Hi all,
Can some one show me how to achieve a cross product of arrays. So that if I
had two arrays (could be any number) with three elements in each (once again
could be any number) I would get:...
|
by: Charles |
last post by:
I'd like to develop a simple cross-platform application in C++. I'd
like it to run in Windows, OS X, PC-BSD and Linux. From my research, it
seems I should use Qt or Gtk as a graphical library. Do...
|
by: Bart Van der Donck |
last post by:
Hello,
I'm presenting my new library 'AJAX Cross Domain' - a javascript
extension that allows to perform cross-domain AJAX requests.
http://www.ajax-cross-domain.com/
Any comments or...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
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...
| |