Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Posts
    8

    Unanswered: Help Needed Creating a View

    Dear Sirs et Madames,
    I have a source table which has the following columns:

    * name
    * date_of_birth
    * gender.

    I need to create a view with three columns:

    * age_range
    * number_of_males
    * number_of_females

    the age range column should contain the values 0-4,5-9,10-14,15-19,...,85+ in those intervals until the last row should read 85+ in the age_range column ( so in total I will have 23 rows in this view).

    The number_of_males column should contain the count of the number of males who fit in the corresponding age_range in the year 2000 (they may not fit it now i.e be alot older but the only condition is that in the year 2000 they fit into that particular age_range).

    The number_of_females column is the same as the number_of_males column except it is for females.

    Can anyone assist me on how such a view could be written?

    Thanks in advance

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    What have you tried so far?
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Sep 2010
    Posts
    8
    Ignoring the first column, just attempting to get the counts I have tried:

    create view pop_pyramid_2000 (male,female) AS
    (select count(*) from "rufiji_individual" where sex='M',select count(*) from "rufiji_individual" where sex='F').

    That does not work...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •