Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Posts
    4

    Unanswered: simple query question

    I have a table that looks like this:

    x type
    - ----
    1 0
    2 0
    1 1
    2 1
    3 1

    How do I query it to get this:

    type0 type1
    ----- ------
    1 1
    2 2
    NULL 3

    the formatting is messed up, but there are 2 fields: type0 with records 1,2,NULL and type1 with records 1,2,3
    Thanks In Advance

  2. #2
    Join Date
    Oct 2001
    Location
    Bay Area, CA
    Posts
    117
    With a crosstab query, here's the sql:

    TRANSFORM First(types.x) AS FirstOfx
    SELECT types.x
    FROM types
    GROUP BY types.x
    PIVOT types.Type;


    hope this helps...

  3. #3
    Join Date
    Jan 2002
    Posts
    4
    Thank you so much, Torgue! I pretty much designed a whole database application and until now, never had to learn crosstab queries. I guess that says something about the application too

    Thanks again.

Posting Permissions

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