Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Age Stats Report Help Please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Age Stats Report Help Please

    We have a DOB field in a MYSQL table.

    We would like to show in a report, the number of members in our club, whose age is between 65-74, 75-84 and 85+.

    Your suggestions for the report and syntax would be appreciated.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    #2
    Re: Age Stats Report Help Please

    Is it a date field that the DOB is stored in?

    Comment


      #3
      Re: Age Stats Report Help Please

      Assuming it is a date field. You can do something like this in your select statement to get the age of the person.

      I would create a view and add the below to the select statement to give you the age

      SELECT DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(dob)), '%Y')+0 AS age FROM YourTableorView

      Then you can do a simple filter expression to get the data you need from your age ranges.

      Comment


        #4
        Re: Age Stats Report Help Please

        Hi Josh,

        Thanks for your replies. Yes the DOB is a date field.

        If we use the SELECT statement as you have it, will that enable us to get the number of members in the age ranges shown above on the same report?
        Regards
        Keith Hubert
        Alpha Guild Member
        London.
        KHDB Management Systems
        Skype = keith.hubert


        For your day-to-day Needs, you Need an Alpha Database!

        Comment


          #5
          Re: Age Stats Report Help Please

          It's a start. It gives you the age of the person you need in the format you need it in.

          Then you could do something like this. Create a calculated column in your report for each of your age ranges and I think something like this would work.

          Calculated Column 1: Expression=between_num(convert_type(age,"C"),65,74) then set the calculated column to provide the COUNT of the records when it prompts you
          Calculated Column 2: Expression=between_num(convert_type(age,"C"),75,84) then set the calculated column to provide the COUNT of the records when it prompts you
          Calculated Column 3. Expression=AGE >= 85 then set the calculated column to provide the COUNT of the records when it prompts you

          Normally I would place this type of information in a group header or footer of a report but I am unsure of your exact requirements.
          Last edited by coleresources; 02-20-2014, 09:21 PM.

          Comment


            #6
            Re: Age Stats Report Help Please

            Josh,

            Thanks for this, will give a try and let you know.
            Regards
            Keith Hubert
            Alpha Guild Member
            London.
            KHDB Management Systems
            Skype = keith.hubert


            For your day-to-day Needs, you Need an Alpha Database!

            Comment


              #7
              Re: Age Stats Report Help Please

              Josh .............

              I'm working on this with Keith. Thanks for your efforts. It is not getting us what we need unfortunately.

              Here is our Select Statement (which get the same results as your Select statement above:)

              SELECT SCLL_MEM_ID, DOB, YearsBetweenDates(DOB, CurrentDate() ) AS Age, STATUS FROM scll_members_tbl

              This gets:

              "Members Id" : "DOB" : "Age" (in years) : and : "Status" (Membership type)

              There are 12 records in the query.

              I have tried some Calculated Values

              Age_Range_65_74 = between(age,65,74) This produeces T or F

              Count_1 = count(calc->Age_Range_65_74 =.T.) I was hopeing this count count the T

              cnt_calc_Count_1_for_Grand = count(calc->Count_1,grp->Grand,grp->Grand) Have put this in the Footer and results in 1 when it should be 4

              I had hoped that getting the age in years from the select statement would enable a Between function to get just the records with age in the 65 - 74 range but no luck.

              We either get 0, 1 or 12 not the 4 that meet the criteria.

              Would be grateful for any further thoughts.


              Thanks for your help.

              John
              John

              Currently Using Alpha ver 12.4.4.4. Build: 4346; Addins: 4889 against MySql databases

              Church Job Finder
              A Church of England Enabling Recruitment Partner "Right People, Right Place, Right Time"

              Comment


                #8
                Re: Age Stats Report Help Please

                Try

                TIMESTAMPDIFF(YEAR,DOB,CURDATE()) AS age

                Cheers

                Glen
                Glen Schild



                My Blog

                Comment


                  #9
                  Re: Age Stats Report Help Please

                  Hey John...What if you do a

                  between_num(convert_type(age,"C"),65,74) = .t. and then select it to gather the count...Does that work?

                  Comment


                    #10
                    Re: Age Stats Report Help Please

                    Josh ............

                    Thank for your suggestions. They work to a point.

                    Our Select statement is getting us the Age in years using the 2 suggestions:

                    SELECT SCLL_MEM_ID, DOB, YearsBetweenDates(DOB, CurrentDate() ) AS Age, STATUS FROM scll_members_tbl

                    and

                    TIMESTAMPDIFF(YEAR,DOB,CURDATE()) AS age

                    Using Between in a calculated expression returns all 12 records in the query. We know only 4 meet the criteria.

                    Age_65_74_2 = If(Age>=65.AND.Age<=74,.T.,.F.) returns .T. or .F.

                    As we can get .T. or .F. results we should be able to do a count of the .T. records but we are not having much sucess.

                    We have tried a Count of .T. as a calculated expression Count_Age_65_74_2 = Count(calc->Age_65_74_2,GRP->detail)=.T but this returns just .F.

                    In the footer we tried cnt_calc_count_1_for_Grand = count(calc->count_1,grp->Grand,grp->detail) This returns all 12.

                    Are we missing something?

                    Any further thoughts would be gratefully recieved.

                    Thanks

                    John
                    John

                    Currently Using Alpha ver 12.4.4.4. Build: 4346; Addins: 4889 against MySql databases

                    Church Job Finder
                    A Church of England Enabling Recruitment Partner "Right People, Right Place, Right Time"

                    Comment


                      #11
                      Re: Age Stats Report Help Please

                      SELECT scll_mem_id, dob, YearsBetweenDates(dob, CurrentDate() ) AS age, status
                      FROM scll_members_tbl
                      WHERE YearsBetweenDates(dob, CurrentDate() ) > 65 AND YearsBetweenDates(dob, CurrentDate() ) < 74
                      Last edited by GGandhi; 02-24-2014, 10:16 PM.
                      thanks for reading

                      gandhi

                      version 11 3381 - 4096
                      mysql backend
                      http://www.alphawebprogramming.blogspot.com
                      [email protected]
                      Skype:[email protected]
                      1 914 924 5171

                      Comment


                        #12
                        Re: Age Stats Report Help Please

                        Hi Govindan,
                        SELECT scll_mem_id, dob, YearsBetweenDates(dob, CurrentDate() ) AS age, status
                        FROM scll_members_tbl
                        WHERE YearsBetweenDates(dob, CurrentDate() ) > 65 AND YearsBetweenDates(dob, CurrentDate() ) < 74
                        Many thanks for this bit of code.

                        The question that still remains, is how to get the count of number of members in each age range.
                        Regards
                        Keith Hubert
                        Alpha Guild Member
                        London.
                        KHDB Management Systems
                        Skype = keith.hubert


                        For your day-to-day Needs, you Need an Alpha Database!

                        Comment


                          #13
                          Re: Age Stats Report Help Please

                          Keith

                          You can produce a view that will give all the Info you want for your report.

                          If you use Case When Then syntax you can display it as one row or 3 depending on your requirements.

                          If you send me the data you want to return and the table structure I will write the view.


                          Michael

                          You can give me a ring on 01323 895337 if you want.

                          Comment


                            #14
                            Re: Age Stats Report Help Please

                            Code:
                            SELECT 
                            COUNT(*),
                            CASE
                            	WHEN age >=60 AND age <= 70 THEN '60 - 70'
                            	WHEN age >=71 AND age <= 80 THEN '70 - 80'
                            	WHEN age >=81 AND age <= 90 THEN '80 - 90'
                            	END AS ageBand
                            FROM
                            (SELECT TimestampDiff(YEAR, dob, CurDate())
                            AS age
                            FROM scll_members_tbl) AS t1
                            GROUP BY ageBand
                            you need to setup a subquery to do what you want.
                            adjust age the way you want.
                            this will give you the count and the age band
                            I do not know a method that gives individual record then totals it.

                            this is native syntax, not portable alpha build.

                            different layout method

                            Code:
                            SELECT
                            	SUM(IF(age BETWEEN 60 AND 70,1,0)) AS '60 - 70',
                            	SUM(IF(age BETWEEN 71 AND 80,1,0)) AS '70 - 80',
                            	SUM(IF(age BETWEEN 81 AND 90,1,0)) AS '80 - 90'
                            FROM
                            (SELECT TimestampDiff(YEAR, dob, CurDate())
                            AS age
                            FROM scll_members_tbl) AS t1
                            will give you tabular columns.
                            Last edited by GGandhi; 02-25-2014, 08:28 AM.
                            thanks for reading

                            gandhi

                            version 11 3381 - 4096
                            mysql backend
                            http://www.alphawebprogramming.blogspot.com
                            [email protected]
                            Skype:[email protected]
                            1 914 924 5171

                            Comment


                              #15
                              Re: Age Stats Report Help Please

                              I do not know a method that gives individual record then totals it.
                              that was then, not anymore.
                              you can actually list all members in a certain age bracket then give a total count on that group as group total.
                              thanks for reading

                              gandhi

                              version 11 3381 - 4096
                              mysql backend
                              http://www.alphawebprogramming.blogspot.com
                              [email protected]
                              Skype:[email protected]
                              1 914 924 5171

                              Comment

                              Working...
                              X