473,407 Members | 2,306 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,407 software developers and data experts.

Trouble with a multi level query

Hi,

I am having trouble with the following query.

I need to sort from a list of contacts the last date each was contacted.

This is to be represented in days so for instance:

0-42 days since last contact I have where

First = Previous Contact
Closed = To filter no longer required

Expand|Select|Wrap|Line Numbers
  1. SELECT Count(*) AS Expr1, Date()-[first] AS Expr2, Contacts.Closed
  2. FROM Contacts
  3. GROUP BY Date()-[first], Contacts.Closed
  4. HAVING (((Date()-[first]) Between 0 And 42) AND ((Contacts.Closed) Is Null));
  5.  
My idea is to create similar queries for 42-91 days etc then merge them into one query to run a report from.

The 2 problems I am having are

1. The way I have implemented the count function is in error, I can't figure how to count individual records. The current logic is grouping similar dates and then counting only unique dates. (I'm sure this is straight forward but I can't think of how!)

2. How to merge the totals into one query. The only information I need are the totals, this one I don't have a clue how to do.

Thanks for reading

Stephen
Oct 22 '07 #1
3 1611
Rabbit
12,516 Expert Mod 8TB
1. The way I have implemented the count function is in error, I can't figure how to count individual records. The current logic is grouping similar dates and then counting only unique dates. (I'm sure this is straight forward but I can't think of how!)
I'm having trouble understanding this. What do you mean by count individual records? If you could provide fictitious data and results, it'd help me understand what you're looking for.
Oct 22 '07 #2
I'm having trouble understanding this. What do you mean by count individual records? If you could provide fictitious data and results, it'd help me understand what you're looking for.
Hi, thanks for checking by, I got myself sorted on both points.

When I came back to look I realised I had Group By instead of Where placed in the SQL. Really straight forward mistake on my part.

Thanks again

Stephen
Oct 22 '07 #3
Rabbit
12,516 Expert Mod 8TB
Hi, thanks for checking by, I got myself sorted on both points.

When I came back to look I realised I had Group By instead of Where placed in the SQL. Really straight forward mistake on my part.

Thanks again

Stephen
Glad you got it working.
Oct 22 '07 #4

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

Similar topics

4
by: eliffman | last post by:
I get the following error when trying to run a report: Multi-level GROUP BY clause is not allowed in a subquery. (Error 3612) The report's recordsource is a query based on a single table....
1
by: Tim Marshall | last post by:
A2003. I am getting this error message when I try to set a report's recordsource to an SQL statement or a saved querydef that uses sub-queries. I've debug.printed the SQL, and run it as a stand...
4
by: snowweb | last post by:
I am trying to implement a CSS hierarchical unfolding menu on a site. The thing is, it needs to be dynamically populated from the results of a database query. I previously had the menu working but...
6
by: dbuchanan | last post by:
There are three parts to this 1.) How do I cascade menus? 2.) And, how do I cascade menus with a multi-select CheckBoxList?
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.