Re: Totals Query
From: James (anonymous_at_discussions.microsoft.com)
Date: 04/05/04
- Next message: Gary Walter: "Re: Drop Primary Key with SQL/VBA"
- Previous message: Sabine: "count empty boxes"
- In reply to: Gerald Stanley: "Re: Totals Query"
- Next in thread: Gerald Stanley: "Re: Totals Query"
- Reply: Gerald Stanley: "Re: Totals Query"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 5 Apr 2004 01:22:20 -0700
Ok I have added a Field called Source... Is there any
relevance to this field?? or could it be changed?
Also how do I get the Combo Boxes encorportated into this?
By the fact that what ever is in the combo boxes it comes
up and tells you the percentage of what is in the database
to the selections made... so for example...
There are 20% of everything in the database which are Male
and to Q2 they answered False!!
Many Thanks
James
>-----Original Message-----
>
>>-----Original Message-----
>>What are they selecting - different columns from your
table
>>or different values from the same column?
>>
>>Diffent Colums from diffent table(s)....
>>
>>
>>Maintable.Source was taken directly from you original
>>>queries. Please remember that we cannot see your table
>>>structures so we take it on faith that you have quoted
the
>>>column names correctly
>>
>>This I know...
>>
>>What is the source though what sort of thing would I be
>>looking for? could you give me a brief example.. of a
made
>>up table's and there source??
>
>Look at the table called Maintable in Design View and it
>will show you the column names. One of these should be
>called source.
>
>>
>>That way I could get an Idea of whta I am looking for...
>>
>>Many Thanks
>>
>>James
>>
>>
>>
>>>-----Original Message-----
>>>
>>>>-----Original Message-----
>>>>Hi,
>>>>
>>>>The code I have was given to me by someone else on
>>here..
>>>>Will it work?
>>>
>>>As long as you enclose Number in [], it should be
fine.
>>It
>>>is bad practice to use reserved words as column names
>>which
>>>is why I names the Count column as SourceCount.
>>>
>>>>
>>>>Also in your code below it mentiones Maintable.Source
ok
>>>>fine... but what would I be looking for in regards to
>>the
>>>>source???
>>>
>>>Maintable.Source was taken directly from you original
>>>queries. Please remember that we cannot see your table
>>>structures so we take it on faith that you have quoted
the
>>>column names correctly
>>>
>>>>
>>>>And where you say SourceCount I take it this mean teh
>>>>Source mentioned above?
>>>
>>>That is the name I gave to the count column. You can
name
>>>it whatever you like but bear in mind the previous
comment
>>>about using reserved words as column names.
>>>
>>>>
>>>>So will I only need the one query shown below or all
>>three
>>>>which I have and add yours in?
>>>
>>>My query should replace your 3 queries.
>>>
>>>
>>>>
>>>>As for the combo box....
>>>>
>>>>Well I just have three combo boxes where I need there
>>>>values in the query so it can do the percentage of the
>>the
>>>>total records by the selections made by the user in
the
>>>>three combo boxes...
>>>>
>>>
>>>What are they selecting - different columns from your
>>table
>>>or different values from the same column?
>>>
>>>>Many Thanks
>>>>
>>>>James
>>>>>-----Original Message-----
>>>>>I think that the following may give you what you are
>>after
>>>>>
>>>>>SELECT Maintable.source, Count(1) AS SourceCount, 100
*
>>>>>Count([1])/(Select Count(*) FROM Maintable) AS
>>>>SourcePercentage
>>>>>FROM Maintable
>>>>>GROUP BY Maintable.source;
>>>>>
>>>>>Try to avoid using reserved words as column names.
If
>>you
>>>>>must, then place them in []
>>>>>
>>>>>You will have to repost to this thread to explain
>>further
>>>>>about including combo boxes in this query.
>>>>>
>>>>>Hope This Helps
>>>>>Gerald Stanley MCSD
>>>>>>-----Original Message-----
>>>>>>I have the following code which I was given:
>>>>>>
>>>>>>Well this SQL query:
>>>>>>
>>>>>>--------------------------------
>>>>>>SELECT maintable.source, COUNT(maintable.source) AS
>>>>Number
>>>>>>FROM maintable
>>>>>>GROUP BY maintable.source;
>>>>>>--------------------------------
>>>>>>
>>>>>>will give you the number of each source.
>>>>>>
>>>>>>This query:
>>>>>>
>>>>>>--------------------------------
>>>>>>SELECT COUNT(*) AS NumberOfRecords
>>>>>>FROM maintable;
>>>>>>--------------------------------
>>>>>>
>>>>>>will give the total number of records.
>>>>>>
>>>>>>Lets call them Query1 and Query2 respectively, then
I
>>>>>>think this query:
>>>>>>
>>>>>>--------------------------------
>>>>>>SELECT Query1.source,
>>>>>>Query1.Number/Query2.NumberOfRecords*100 AS
Percentage
>>>>>>FROM Query1, Query2;
>>>>>>--------------------------------
>>>>>>
>>>>>>
>>>>>>Ok so whats my source in the table please could you
>>help
>>>>>>with this??
>>>>>>
>>>>>>Also I have to get the combo boxes somehow into this
>>>>query
>>>>>>does anyone out there have any idea how to do this?
>>>>>>
>>>>>>Also this reserved word thing... I have done the
>>>>>>following: "Number" and the error goes away would
the
>>>>code
>>>>>>still run or would it treat Number as something
>>diffrent
>>>>>>now?
>>>>>>
>>>>>>Many Thanks
>>>>>>
>>>>>>James
>>>>>>>-----Original Message-----
>>>>>>>Hmm.
>>>>>>>The combo boxes must be bound to an object right.
So,
>>I
>>>>>>dunno what exactly you need to do.
>>>>>>>As for reserved words, well that's always a huge
pain
>>>>in
>>>>>>the butt. You're going to have to get rid of them
>>>>somehow.
>>>>>>Just change it for something else I guess.
>>>>>>>.
>>>>>>
>>>>>>.
>>>>>>
>>>>>.
>>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>
- Next message: Gary Walter: "Re: Drop Primary Key with SQL/VBA"
- Previous message: Sabine: "count empty boxes"
- In reply to: Gerald Stanley: "Re: Totals Query"
- Next in thread: Gerald Stanley: "Re: Totals Query"
- Reply: Gerald Stanley: "Re: Totals Query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|