A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

[acess2003][yupyupxav] Grouping low values in a sum



 
 
Thread Tools Display Modes
  #1  
Old December 14th, 2008, 02:35 PM posted to microsoft.public.access.queries
yupyupxav
external usenet poster
 
Posts: 6
Default [acess2003][yupyupxav] Grouping low values in a sum

Hello all,

I have a table with a field
designator : text
total : date (where I store a duration, always smaller than 24h)

I want to do a sum by designator, so far no problems but I want to
group small values (here designators with sums less than 24h=1)

i therefore use this syntax for my query:

SELECT DISTINCTROW IIf(Sum(total)1,designator,"other") AS D,
Sum([QFlights.total]) AS sumofTotal
FROM qflights
GROUP BY qflights.Designator;


My problem is that I get several results with "Other" as designator,
and I'd like access to add all small values (other thus with a
Sumoftotal1) in a single designator "Other"

i have thus

D ! SumOfTotal
------------------------------
S61 ! 2,3
Other! 0,65
F260 ! 19,45
E121 ! 20,46
Other ! 0,23
Other! 0,96
AJET ! 40,34


I want thus access to group all values "Other" and give the result
(0.65+0.23+0.96)


Is this feasible?

Thanks!

Xav
  #2  
Old December 14th, 2008, 03:09 PM posted to microsoft.public.access.queries
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default [acess2003][yupyupxav] Grouping low values in a sum

Try:

SELECT IIf(S.TotalAmt =1, "other", S.Designator) AS D,
Sum(S.TotalAmt) AS sumofTotal
FROM
(
SELECT [designator],
Sum([QFlights.total]) AS sumofTotal
FROM qflights
GROUP BY qflights.Designator) AS S
GROUP BY IIf(S.TotalAmt =1, "other", S.Designator)


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"yupyupxav" wrote in message
...
Hello all,

I have a table with a field
designator : text
total : date (where I store a duration, always smaller than 24h)

I want to do a sum by designator, so far no problems but I want to
group small values (here designators with sums less than 24h=1)

i therefore use this syntax for my query:

SELECT DISTINCTROW IIf(Sum(total)1,designator,"other") AS D,
Sum([QFlights.total]) AS sumofTotal
FROM qflights
GROUP BY qflights.Designator;


My problem is that I get several results with "Other" as designator,
and I'd like access to add all small values (other thus with a
Sumoftotal1) in a single designator "Other"

i have thus

D ! SumOfTotal
------------------------------
S61 ! 2,3
Other! 0,65
F260 ! 19,45
E121 ! 20,46
Other ! 0,23
Other! 0,96
AJET ! 40,34


I want thus access to group all values "Other" and give the result
(0.65+0.23+0.96)


Is this feasible?

Thanks!

Xav



  #3  
Old December 14th, 2008, 04:56 PM posted to microsoft.public.access.queries
yupyupxav
external usenet poster
 
Posts: 6
Default [acess2003][yupyupxav] Grouping low values in a sum

Access keeps asking me what is S.totalAmt



On Sun, 14 Dec 2008 10:09:16 -0500, "Douglas J. Steele"
wrote:

Try:

SELECT IIf(S.TotalAmt =1, "other", S.Designator) AS D,
Sum(S.TotalAmt) AS sumofTotal
FROM
(
SELECT [designator],
Sum([QFlights.total]) AS sumofTotal
FROM qflights
GROUP BY qflights.Designator) AS S
GROUP BY IIf(S.TotalAmt =1, "other", S.Designator)

  #4  
Old December 14th, 2008, 06:24 PM posted to microsoft.public.access.queries
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default [acess2003][yupyupxav] Grouping low values in a sum

Sorry, my typo. Forgot to change the field name.

SELECT IIf(S.TotalAmt =1, "other", S.Designator) AS D,
Sum(S.TotalAmt) AS sumofTotal
FROM
(
SELECT [designator],
Sum([QFlights.total]) AS TotalAmt
FROM qflights
GROUP BY qflights.Designator) AS S
GROUP BY IIf(S.TotalAmt =1, "other", S.Designator)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"yupyupxav" wrote in message
...
Access keeps asking me what is S.totalAmt



On Sun, 14 Dec 2008 10:09:16 -0500, "Douglas J. Steele"
wrote:

Try:

SELECT IIf(S.TotalAmt =1, "other", S.Designator) AS D,
Sum(S.TotalAmt) AS sumofTotal
FROM
(
SELECT [designator],
Sum([QFlights.total]) AS sumofTotal
FROM qflights
GROUP BY qflights.Designator) AS S
GROUP BY IIf(S.TotalAmt =1, "other", S.Designator)



  #5  
Old December 14th, 2008, 07:20 PM posted to microsoft.public.access.queries
yupyupxav
external usenet poster
 
Posts: 6
Default [acess2003][yupyupxav] Grouping low values in a sum

Thank you very much douglas. This makes the Job. You're a genius.

Xav

On Sun, 14 Dec 2008 13:24:56 -0500, "Douglas J. Steele"
wrote:

Sorry, my typo. Forgot to change the field name.

SELECT IIf(S.TotalAmt =1, "other", S.Designator) AS D,
Sum(S.TotalAmt) AS sumofTotal
FROM
(
SELECT [designator],
Sum([QFlights.total]) AS TotalAmt
FROM qflights
GROUP BY qflights.Designator) AS S
GROUP BY IIf(S.TotalAmt =1, "other", S.Designator)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.