473,789 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with a multi level query

10 New Member
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 1631
Rabbit
12,516 Recognized Expert Moderator MVP
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
lostdawg
10 New Member
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 Recognized Expert Moderator MVP
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
3757
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. However, one of the fields in the query is a subquery. This field is also used in the calculations for a few other fields in the query. I'm able to run the report with no group levels. But the addition of even one group level causes the error.
1
7208
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 alone query, as a rowsource for a list box and as a recordsource for a form. There's no problem. I'm only encountering this in reports. As a stop gap, I'm going to use a form for a printe report, bvut I wonder if anyone has encountered...
4
19113
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 then it was ‘hard coded’ and not built on the fly. Menu description: 2 top level items “Company” and “Products” (we will ignore “Company” since it is still hard coded and not causing a problem. Below “Products” we have hard coded “By...
6
3511
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
9666
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.