473,699 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MAX and Grouping

Hi All..I have been using Access for about 10 years now but something
occurred to me that when I'm trying to GROUP and MAX, it's pulling it
for different fields.

Example:

I have times by hour (field name CSTHR)

08:00am 50
09:00am 55
10:00am etc. 65

and I have a total calls per second.(field name TOTALCCS)

I'm trying to get the busiest hour of the day using MAX..If I take off
CSTHR out of the grouping it shows me the max for the query (i.e.,
65). I also want the correct time to show up (i.e., 10:00am) but if I
do FIRST, LAST, MIN, or MAX on the CSTHR column, it doesn't correlate
to the correct record..It shows a different time for that field
instead of the correct record I may want to add other fields in the
record like ID, DATE, etc. to show up on that line.

I need to have the results like this:

10:00am 65

and NOT

08:00am (if using first) and MAX of 65.

I have read other articles and some of them don't make sense and I
can't get this to work..Anybody helps me I would greatly appreciate it!

Jun 27 '07 #1
8 1674
Hi Chris,

Could you post some sample data: like

1)

fld1 fld2 fld3 fld4 ...
xyz 123 8am 15
yyz 445 8:15am 20
mtr 292 8:20am 17
...
2)
and then post some sample data of your actual query results - maybe
include the sql for the query

3)
and then post a sample of how you want the data to appear in the query
result

this will make it easier to visualize your problem (well, for me anyway)
and then find a solution.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '07 #2
JHB
Hello,
try, (repalce "Table2" with your table name.

SELECT Tabel2.CSTHR, Tabel2.TOTALCCS
FROM Tabel2
WHERE (((Tabel2.TOTAL CCS)=(SELECT Max(Tabel2.TOTA LCCS) AS fTOTALCCS FROM
Tabel2;)));

Regards
Jørn
"chrisdavis " <pi************ *@gmail.comskre v i en meddelelse
news:11******** **************@ u2g2000hsc.goog legroups.com...
Hi All..I have been using Access for about 10 years now but something
occurred to me that when I'm trying to GROUP and MAX, it's pulling it
for different fields.

Example:

I have times by hour (field name CSTHR)

08:00am 50
09:00am 55
10:00am etc. 65

and I have a total calls per second.(field name TOTALCCS)

I'm trying to get the busiest hour of the day using MAX..If I take off
CSTHR out of the grouping it shows me the max for the query (i.e.,
65). I also want the correct time to show up (i.e., 10:00am) but if I
do FIRST, LAST, MIN, or MAX on the CSTHR column, it doesn't correlate
to the correct record..It shows a different time for that field
instead of the correct record I may want to add other fields in the
record like ID, DATE, etc. to show up on that line.

I need to have the results like this:

10:00am 65

and NOT

08:00am (if using first) and MAX of 65.

I have read other articles and some of them don't make sense and I
can't get this to work..Anybody helps me I would greatly appreciate it!

Jun 27 '07 #3
On Jun 27, 2:49 pm, "JHB" <w...@ofir.dkwr ote:
Hello,
try, (repalce "Table2" with your table name.

SELECT Tabel2.CSTHR, Tabel2.TOTALCCS
FROM Tabel2
WHERE (((Tabel2.TOTAL CCS)=(SELECT Max(Tabel2.TOTA LCCS) AS fTOTALCCS FROM
Tabel2;)));

Regards
Jørn

"chrisdavis " <pianoplayerd.. .@gmail.comskre v i en meddelelsenews: 11************* *********@u2g20 00hsc.googlegro ups.com...
Hi All..I have been using Access for about 10 years now but something
occurred to me that when I'm trying to GROUP and MAX, it's pulling it
for different fields.
Example:
I have times by hour (field name CSTHR)
08:00am 50
09:00am 55
10:00am etc. 65
and I have a total calls per second.(field name TOTALCCS)
I'm trying to get the busiest hour of the day using MAX..If I take off
CSTHR out of the grouping it shows me the max for the query (i.e.,
65). I also want the correct time to show up (i.e., 10:00am) but if I
do FIRST, LAST, MIN, or MAX on the CSTHR column, it doesn't correlate
to the correct record..It shows a different time for that field
instead of the correct record I may want to add other fields in the
record like ID, DATE, etc. to show up on that line.
I need to have the results like this:
10:00am 65
and NOT
08:00am (if using first) and MAX of 65.
I have read other articles and some of them don't make sense and I
can't get this to work..Anybody helps me I would greatly appreciate it!- Hide quoted text -

- Show quoted text -
Hi! The subselect you gave me worked; however how do I group by date
or whatever now? It's looking at the entire table and giving me the
max..I may want to see it by date, or ID, or by hour..cool beans!

Jun 27 '07 #4
On Jun 27, 2:39 pm, Rich P <rpng...@aol.co mwrote:
Hi Chris,

Could you post some sample data: like

1)

fld1 fld2 fld3 fld4 ...
xyz 123 8am 15
yyz 445 8:15am 20
mtr 292 8:20am 17
..

2)
and then post some sample data of your actual query results - maybe
include the sql for the query

3)
and then post a sample of how you want the data to appear in the query
result

this will make it easier to visualize your problem (well, for me anyway)
and then find a solution.

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
Hey Rich..thanks for replying to my ad..I got the subselect to work
for the max but it's looking at the entire table..how do I group by
fields to give me the max for each grouping?

Jun 27 '07 #5
Hi Chris

this may of help

http://www.mvps.org/access/queries/qry0020.htm

chrisdavis wrote:
Hi All..I have been using Access for about 10 years now but something
occurred to me that when I'm trying to GROUP and MAX, it's pulling it
for different fields.

Example:

I have times by hour (field name CSTHR)

08:00am 50
09:00am 55
10:00am etc. 65

and I have a total calls per second.(field name TOTALCCS)

I'm trying to get the busiest hour of the day using MAX..If I take off
CSTHR out of the grouping it shows me the max for the query (i.e.,
65). I also want the correct time to show up (i.e., 10:00am) but if I
do FIRST, LAST, MIN, or MAX on the CSTHR column, it doesn't correlate
to the correct record..It shows a different time for that field
instead of the correct record I may want to add other fields in the
record like ID, DATE, etc. to show up on that line.

I need to have the results like this:

10:00am 65

and NOT

08:00am (if using first) and MAX of 65.

I have read other articles and some of them don't make sense and I
can't get this to work..Anybody helps me I would greatly appreciate it!
Jun 27 '07 #6
On Jun 27, 3:05 pm, John Winterbottom <john...@rogers .cawrote:
Hi Chris

this may of help

http://www.mvps.org/access/queries/qry0020.htm

chrisdavis wrote:
Hi All..I have been using Access for about 10 years now but something
occurred to me that when I'm trying to GROUP and MAX, it's pulling it
for different fields.
Example:
I have times by hour (field name CSTHR)
08:00am 50
09:00am 55
10:00am etc. 65
and I have a total calls per second.(field name TOTALCCS)
I'm trying to get the busiest hour of the day using MAX..If I take off
CSTHR out of the grouping it shows me the max for the query (i.e.,
65). I also want the correct time to show up (i.e., 10:00am) but if I
do FIRST, LAST, MIN, or MAX on the CSTHR column, it doesn't correlate
to the correct record..It shows a different time for that field
instead of the correct record I may want to add other fields in the
record like ID, DATE, etc. to show up on that line.
I need to have the results like this:
10:00am 65
and NOT
08:00am (if using first) and MAX of 65.
I have read other articles and some of them don't make sense and I
can't get this to work..Anybody helps me I would greatly appreciate it!- Hide quoted text -

- Show quoted text -
Hi John..I saw that article before and thanks for sending..I'm trying
to group by DATE or CSTHR or other groupings..The subselect is looking
through the entire table for the MAX and I want to GROUP by different
things..make sense?

Jun 27 '07 #7
In article <11************ **********@w5g2 000hsg.googlegr oups.com>,
pi************* @gmail.com says...
On Jun 27, 2:49 pm, "JHB" <w...@ofir.dkwr ote:
Hello,
try, (repalce "Table2" with your table name.

SELECT Tabel2.CSTHR, Tabel2.TOTALCCS
FROM Tabel2
WHERE (((Tabel2.TOTAL CCS)=(SELECT Max(Tabel2.TOTA LCCS) AS fTOTALCCS FROM
Tabel2;)));

Regards
Jørn

"chrisdavis " <pianoplayerd.. .@gmail.comskre v i en meddelelsenews: 11************* *********@u2g20 00hsc.googlegro ups.com...
Hi All..I have been using Access for about 10 years now but something
occurred to me that when I'm trying to GROUP and MAX, it's pulling it
for different fields.
Example:
I have times by hour (field name CSTHR)
08:00am 50
09:00am 55
10:00am etc. 65
and I have a total calls per second.(field name TOTALCCS)
I'm trying to get the busiest hour of the day using MAX..If I take off
CSTHR out of the grouping it shows me the max for the query (i.e.,
65). I also want the correct time to show up (i.e., 10:00am) but if I
do FIRST, LAST, MIN, or MAX on the CSTHR column, it doesn't correlate
to the correct record..It shows a different time for that field
instead of the correct record I may want to add other fields in the
record like ID, DATE, etc. to show up on that line.
I need to have the results like this:
10:00am 65
and NOT
08:00am (if using first) and MAX of 65.
I have read other articles and some of them don't make sense and I
can't get this to work..Anybody helps me I would greatly appreciate it!- Hide quoted text -
- Show quoted text
not sure I am of any help, but

FORMAT(DateAdd( "h",DATEDiff("h ",0,[your datetime column]),0),"Medium Time")AS
[HOUR]

GROUP BY DateAdd("h",DAT EDiff("h",0,[your datetime column]),0)

Jun 27 '07 #8
Chris, post your simplified table structure, preferably as a CREATE
TABLE script with some sample data and the output you want.

chrisdavis wrote:
On Jun 27, 3:05 pm, John Winterbottom <john...@rogers .cawrote:
>Hi Chris

Hi John..I saw that article before and thanks for sending..I'm trying
to group by DATE or CSTHR or other groupings..The subselect is looking
through the entire table for the MAX and I want to GROUP by different
things..make sense?
Jun 28 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1874
by: Debbie Davis | last post by:
Hi there, SQL 2000 I have the following query: SELECT sponsor, COUNT(sponsor) * 2 AS total FROM Referrals GROUP BY sponsor Works great, returns the sponsor and the total * 2 of their referrals
3
1811
by: Graham | last post by:
Hi, I am having trouble getting XSL to count the members of a group. What I am trying to do is group by <objectid.Contactid> and count the number of <activityid>'s for each <objectid.contactid>. My XSL keeps returning zero for the count. The results for the XML/XSLT files below should look like:- Contact # of Visits Account ----------------------------------------------------------
1
2886
by: amber | last post by:
Hello, I have a report in VB.NET/Crystal Reports. I have a criteria form that users select between 2 different types of grouping (group by category or group by year). Can I programmatically change the grouping of a single report, based on the user's selection? Or do I have to create another report, with different grouping, and call it when user selects different grouping? Thanks, amber
2
1700
by: Andreas Håkansson | last post by:
Seeing how my previous post seem to have fallen between the cracks, I thought I would have a second, more direct, go at it. So my question is "Is it possible to group (Muenchian method) over multiple nodes?" I will use an example to try to explain what I need to do and what I have for data. The example might not be very realistic but it's much easier than to try and explain using the scenario I have =P Suppose I had a list of...
3
2735
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have reports at the plan (overall totals), department and division levels which have sorting and grouping implemented with this new
8
3531
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word templates, and the queries that drive them, depending on what events a course has.
0
1221
by: Corey | last post by:
hello, I’m trying to run a query and I’m getting error messages Can anyone help me get though this problem? 1: Tried this and got this error message ORA-00923 , decode (grouping(dsd.Field1,'RETURNED', COUNT(*), 0)) Net1 , decode (grouping(dsd.field1,'COMPLETED', COUNT(*), 0)) Net2
0
1530
by: Roman Bertle | last post by:
Hello, I try to format monetary values using the locale module, python2.5: Python 2.5.2a0 (r251:54863, Jan 3 2008, 17:59:56) on linux2 Type "help", "copyright", "credits" or "license" for more information. 'de_AT.utf8' {'mon_decimal_point': ',', 'int_frac_digits': 2, 'p_sep_by_space': 1, 'frac_digits': 2, 'thousands_sep': '', 'n_sign_posn': 1,
1
5690
by: Sandeep Singh | last post by:
Hi, How to do group by in XSLT ? I tried on the following codes: <files> <file name="swablr.eps" size="4313" project="mars"/> <file name="batboy.wks" size="424" project="neptune"/> <file name="potrzebie.dbf" size="1102" project="jupiter"/>
6
1647
patjones
by: patjones | last post by:
Good afternoon: This seems like it shouldn't be hard, and then again this is how so many problems seem at the outset. My situation is this: I have a report called rptMain319, which is based on a table tblMain319. The report groups employees by their work location (). By putting a Count(*) function in the footer for the Payroll Distribution grouping, I can get the total number of employees in that particular work location. My problem...
0
8686
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
8615
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
9033
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
8911
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
8882
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
7748
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...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3057
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
3
2009
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.