My Assistant
![]() ![]() |
|
|
Oct 8 2009, 02:09 PM
Post
#1
|
|
|
UtterAccess Addict Posts: 147 |
hi all I wonder if I can group using 2 fields . Let's Say I have a table and in there I have field1 and field2 and field3
field1 field2 field3 1 111 1 222 1 333 444 So base on data above let's say active is 1. So grouping by 1 I got 3 counts and not active(nothing or 0) I got one count. Or do I have 2 create 2 queries and join them? Someone has an idea? thanks |
|
|
|
Oct 8 2009, 02:18 PM
Post
#2
|
|
|
Access Wiki and Forums Moderator Posts: 48,599 From: SoCal, USA |
Hi,
Your example did not display as you probably intended. To fix that, you'll need to use a "code" block. As you type your post, click on the "Code" link below to create a code block, then you can type your code inside the code block and it will preserve the spaces for display. Just my 2 cents... |
|
|
|
Oct 8 2009, 02:57 PM
Post
#3
|
|
|
UtterAccess Addict Posts: 147 |
CODE field1 field2 field3 1 111 444 1 222 1 333 Thanks alot DBguy |
|
|
|
Oct 8 2009, 03:21 PM
Post
#4
|
|
|
Access Wiki and Forums Moderator Posts: 48,599 From: SoCal, USA |
You're welcome. It makes a lot more sense now!
Based on your limited sample, you may be able to use a GROUP BY of something like this: GROUP BY field1 & field2 (untested) Hope that helps... |
|
|
|
Oct 8 2009, 03:33 PM
Post
#5
|
|
|
UtterAccess Addict Posts: 147 |
thanks DB guy it works well I have tested it. One more question how can you count how many people got GPA from 2to 3 and from 3 to 4... something like that...do you have any idea?
thanks |
|
|
|
Oct 8 2009, 03:42 PM
Post
#6
|
|
|
Access Wiki and Forums Moderator Posts: 48,599 From: SoCal, USA |
Glad to hear that!
I would try something like: SELECT Sum(IIf(GPA Between 2 And 2.99, 1, 0)) As GPA2To3, Sum(IIf(GPA Between 3 And 3.99, 1, 0)) As GPA3To4 FROM TableName Either that, or look into the Partition() function. (untested) Hope that helps... |
|
|
|
Oct 8 2009, 03:45 PM
Post
#7
|
|
|
UtterAccess Addict Posts: 147 |
Oh I just got it using Sum(IIf([CumulativeGPA]>=2.5 And [CumulativeGPA]<=2.99,1,0)) as expression I have tested it and got correct result . If I want to have sum of my count for each group or percentage for each female or male over total of each group in report .. will I create unbound field in report or in query?
thanks DBguy |
|
|
|
Oct 8 2009, 04:54 PM
Post
#8
|
|
|
Access Wiki and Forums Moderator Posts: 48,599 From: SoCal, USA |
Hi,
Glad to hear you were able to make it work! I think you can perform the calculation in either one but I would suggest trying the Query first and if it doesn't work, try the Report. Hope that helps... |
|
|
|
Oct 8 2009, 04:59 PM
Post
#9
|
|
|
UtterAccess Addict Posts: 147 |
thanks DBguys I will try it later.
Once again Thanks |
|
|
|
Oct 8 2009, 05:38 PM
Post
#10
|
|
|
Access Wiki and Forums Moderator Posts: 48,599 From: SoCal, USA |
You're very welcome. Good luck with your project.
|
|
|
|
Oct 8 2009, 05:46 PM
Post
#11
|
|
|
UtterAccess Addict Posts: 147 |
Hi,
but this one seem easy but I have no clue to do it in query or report when calculate total or percentage from each group. Let's me give you an example CODE percentage Group A Active Female 1 1/3 Male 2 2/3 Total 3 50% Not Active Female 1 1/3 Male 2 2/3 Total 3 50% Total Group A 6 100% so let's say I got data for each active and not active , how can I do this kind of report using query or report to come up to this percentage number for each groupA and GroupB ...and so on. I think you did this kind of report before but I have no idea to do it in query or report ...since I did a little of sum or total only. I hope you understand example above . Could anyone help me with this? thanks |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 04:45 AM |