473,387 Members | 1,365 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,387 software developers and data experts.

GROUP BY ALL type query needed

I want to list all groups within my data regardless of whether they meet a certain condition - if they do not meet the condition I want to display a count of 0 for the relevant groups.

Access Query Question:

Using Access 2003 SP2.

I wanted to use the 'GROUP BY ALL' command but apparently this cannot be used with remote tables and Microsoft no longer support the 'ALL' command with future releases.

I want a list of all referral sources for all new customers regardless of whether they have placed an order or not - if a group has no orders placed I want the count to be 0.

e.g. code:

Expand|Select|Wrap|Line Numbers
  1. SELECT Customer.Refer, Count(*) AS Orders
  2. FROM Customer
  3. WHERE (((Customer.Date) Between #1/1/2007# And ((#1/8/2007#)+1)) 
  4. AND ((Customer.Notes) Like '*<Orders>*1*</Orders>*' 
  5. Or (Customer.Notes) Like '*<Orders>*2*</Orders>*' 
  6. Or (Customer.Notes) Like '*<Orders>*3*</Orders>*' 
  7. Or (Customer.Notes) Like '*<Orders>*4*</Orders>*' 
  8. Or (Customer.Notes) Like '*<Orders>*5*</Orders>*' 
  9. Or (Customer.Notes) Like '*<Orders>*6*</Orders>*' 
  10. Or (Customer.Notes) Like '*<Orders>*7*</Orders>*' 
  11. Or (Customer.Notes) Like '*<Orders>*8*</Orders>*' 
  12. Or (Customer.Notes) Like '*<Orders>*9*</Orders>*' 
  13. Or (Customer.Notes) Like '*<Orders>*0*</Orders>*'))
  14. GROUP BY  Customer.Refer
Result:

Expand|Select|Wrap|Line Numbers
  1. REFER | ORDERS
  2. <NULL> | 500
However I want all other 'refer' sources to also be listed e.g.

Expand|Select|Wrap|Line Numbers
  1. REFER | ORDERS
  2. <NULL> | 500
  3. REFA | 0
  4. REFB | 0
  5. REFC | 0
The GROUP BY ALL does not work - I get the following error:

"Syntax Error (missing operator) in query expression 'ALL customer.refer'"

Note: On a separate point my 'Where' clause looks complicated because I only know if an order has been placed by looking at a 'memo' field searching for the following pattern "<Orders>####<Orders/>" (where #### can be any number combination - I have not been able to find an easier way to search for a string pattern (any guidance would be greatly appreciated).
Jun 21 '07 #1
4 2117
NeoPa
32,556 Expert Mod 16PB
I would state confidently, that the SQL you posted does NOT match the error message posted.
Please check and post (using Copy/Paste) the matching pair.
Jun 24 '07 #2
NeoPa
32,556 Expert Mod 16PB
It is also difficult to work without the actual data (this is however necessary most times as data is hard to post sensibly), but would your <Orders> information not be detectable simply with the "Like '*<Orders>*</Orders>'" check. Not if you have all non-numeric characters in any order number, but do you have that? I'll leave that with you.
Jun 24 '07 #3
Thank you for your help. I have resolved the problem by using three separate queries - getting the data into the exact format that I require.

You are right the error message reported did not match the data shown - the message was right it was just the table reference that was different.

Thanks again for replying - much appreciated.
Jul 6 '07 #4
NeoPa
32,556 Expert Mod 16PB
No problem.
I'm glad you managed to resolve your issue :)
Jul 6 '07 #5

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

Similar topics

1
by: George | last post by:
Hi, I am trying to write a query in Oracle which I have not done before, and are having some difficulty getting my result. Please check my query and my results. select max(note.datetime),...
2
by: Joshua Moore-Oliva | last post by:
I have a query that is asking me to GROUP a column, yet when I GROUP it it causes an error near GROUP. What is very strange about the following query is that the line list_size_active =...
3
by: Abhi | last post by:
Hi! I am wondering if this query is possible somehow: I have a table with many fields that all can have a value from 1 to 5. if I wanna see the count of each value from one field, then this...
1
by: David Horowitz | last post by:
Hi folks. I need to create a report that has a Group Header that pulls certain data from the Detail section. It's something like this: +--Report---------------------------------------- |...
5
by: Dave Smithz | last post by:
Hi there, Been working on an evolving DB program for a while now. Suddenly I have come across a situation where I need to update a table based on a group by query. For example, I have a table...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
4
by: LF | last post by:
Hello, I have a database with a table of projects and a table of tasks (each project can have multiple tasks). I have a report that has a group header for the project name, etc., and then the...
6
by: cppnow | last post by:
Hello. I have a strange conceptual problem I'm trying to think about. I would like to build a library that allows the user to do the following: 1) User defined types: The user defines their...
5
by: HowHow | last post by:
First time using crosstab query because tired of creating queries and put them together in one query (such a stupid thing to do :D). Not sure how it works still. I have link table called...
0
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,...
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: 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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...

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.