Been busy --
Union query --
SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "TGLLAHIR" AS
[DateType], bukuangkby.TGLLAHIR AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "TGLBPTIS_M" AS
[DateType], bukuangkby.TGLBPTIS_M AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "TGL_pen" AS
[DateType], bukuangkby.TGL_pen AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "ATSPERCA_M" AS
[DateType], bukuangkby.ATSPERCA_M AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "ATSSUR1_K" AS
[DateType], bukuangkby.ATSSUR1_K AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "KMATIAN_K" AS
[DateType], bukuangkby.KMATIAN_K AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "KELMURT_K" AS
[DateType], bukuangkby.KELMURT_K AS TheDate
FROM bukuangkby
UNION SELECT bukuangkby.STAT_CODE, bukuangkby.JnsAngt, bukuangkby.FName,
bukuangkby.MName, bukuangkby.LName, bukuangkby.JenisKel, "KELHILA_K" AS
[DateType], bukuangkby.KELHILA_K AS TheDate
FROM bukuangkby;
TRANSFORM Count(FrankS_Union.TheDate) AS CountOfTheDate
SELECT FrankS_Union.DateType, Count(FrankS_Union.TheDate) AS [Total Of
DateType]
FROM FrankS_Union
GROUP BY FrankS_Union.DateType
PIVOT Format([TheDate],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
OR
TRANSFORM Count(FrankS_Union.TheDate) AS CountOfTheDate
SELECT FrankS_Union.STAT_CODE, FrankS_Union.JnsAngt, FrankS_Union.DateType,
Count(FrankS_Union.TheDate) AS [Total Of DateType]
FROM FrankS_Union
GROUP BY FrankS_Union.STAT_CODE, FrankS_Union.JnsAngt, FrankS_Union.DateType
PIVOT Format([TheDate],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
--
KARL DEWEY
Build a little - Test a little
:
Hello Karl:
I do not seem to have received your response, in case you have not received
here again below the name of the fields. I appreciate your help, this would
be a great help for us.
Thanks Karl for your willingness to help me.
The name of my table is : bukuangkby
The fieldnames, I just mentioned the one that relates to building a
statistics:
Field name Meaning in English
======== ===========
1. STAT_CODE Status whether Active, or Passive or Move
2. JnsAngt Member Type ( Church member or Sabbath School Mem)
3. FName First Name
4. MName Middle Name
5. LName Last Name
6. JenisKel Gender
7. TGLLAHIR Date of Birth
8. TGLBPTIS_M Date Baptized
9. TGL_pen Date Accepted thru transfer
10.ATSPERCA_M Date accepted as member thru faith confession
11.ATSSUR1_K Date Quit thru transfer
12. KMATIAN_K Date of Quit for passed away
13. KELMURT_K Date of Quit becaause of backsliding
14.KELHILA_K Date of Quite for Unknown so reported as lost
The table structure is that all of the fields are in the record but we want
to have a kind of statistics in the 12 months format for:
2 kind of statistics
from inception and for 12 months of current year)
1. From incepttion todate for Row Tittle JnsAngt, column STAT_CODE
2. From Inception todate for JenisKel Column title STAT_CODE
3. 12 months of Current Year : Row title:JnsAngt Column tittle is for All
dates (fields no. 7 to 14).
Sorry Karl to bother you. My software is almost complete and waiting for
this. Actually I want to donate this software to my denomination.
Thanks in advance for your great help
--
H. Frank Situmorang
:
Post your table structure with the actual field names your table has.
--
KARL DEWEY
Build a little - Test a little
:
Sorry Karl, I forgot to copy paste Duane's suggestion: here it is
SELECT [FName],[MName],[LName], "TGLLAHIR" as DateType, [TGLLAHIR] As
TheDate FROM bukuangkby UNION ALL SELECT [FName],[MName],[LName],
"TGLDIBAPTIS", [TGLBPTIS_M] FROM bukuangkby UNION ALL SELECT
[FName],[MName],[LName], "TGL DITERIMA", [TGL_pen] FROM bukuangkby UNION ALL
SELECT [FName],[MName],[LName], "TGLKELUAR", [ATSSUR1_K] FROM bukuangkby;
And here is the crosstab, but I can not make it like yours from Jan to Dec
with option of Year:
TRANSFORM Count([bukuangkby Query_statistics2].TheDate) AS CountOfTheDate
SELECT [bukuangkby Query_statistics2].FName, [bukuangkby
Query_statistics2].MName, [bukuangkby Query_statistics2].LName,
Count([bukuangkby Query_statistics2].TheDate) AS [Total Of TheDate]
FROM [bukuangkby Query_statistics2]
GROUP BY [bukuangkby Query_statistics2].FName, [bukuangkby
Query_statistics2].MName, [bukuangkby Query_statistics2].LName
PIVOT [bukuangkby Query_statistics2].DateType;
Thanks a lot
--
H. Frank Situmorang
:
Carrying Duane's union query (Named FrankS) through into the crosstab ---
TRANSFORM Count(FrankS.TheDate) AS CountOfTheDate
SELECT Replace([DateType],"Date","Number") AS Activity
FROM FrankS
GROUP BY Replace([DateType],"Date","Number")
PIVOT Format([TheDate],"mmm") In
("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
--
KARL DEWEY
Build a little - Test a little
:
What is so dynamic about months of the year. They have been Jan - Dec for as
long as I can remember and I don't think they will ever change ;-)
I believe your issue again is one of un-normalized table structure. You
would need to use a union query to normalize all the dates:
SELECT [Name], "Date Of Birth" as DateType, [Date Of Birth] As TheDate
FROM tblNoName
UNION ALL
SELECT [Name], "Date Of Membership", [Date accepted as member]
FROM tblNoName
UNION ALL
SELECT [Name], "Date Baptized", [Date of Baptized]
FROM tblNoName
UNION ALL
SELECT [Name], "Date Quit", [Date Quit as member]
FROM tblNoName;
You can then make a crosstab query from the union query.
--
Duane Hookom
Microsoft Access MVP
:
Hello,
In my church membership table I have these fields:
1. Name
2. Date of Birth
3. Date accepted as member
4. Date of Baptized
5. Date Quit as member
My question is how can I make a query for statistics in order to know how
many member do we have for each field in 12 months which can be dynamic:
So the outlay is more or less as follows:
Jan Feb Mar...............Dec Total
Number of birht x 0 xx ............... xx
Num of New member xx .................................. xx
Numb of Baptized 0 x 0 3 xx
and so forth
Thanks for anyidea provided.