Results 1 to 2 of 2

Thread: Rows to Column

  1. #1
    Join Date
    Feb 2007
    Posts
    45

    Rows to Column

    Hello,

    I am trying to creating a query where i need to get a count of users for a specific date.

    e.g. for reg_dt = 2007-10-01, there may have been several Forms that were created, and were created by more than one user. What query can i run to get an output like this:

    REG_DT JOHN JENNY
    2007-10-01 4 8

    I am trying the following query. It is giving me the correct count, however, its creating a separate row for each user. e.g. for the above example it creates:

    REG_DT JOHN JENNY
    2007-10-01 4
    2007-10-01 8

    SELECT a.reg_dt, CASE WHEN a.FORM_CREATION_USER_ID = '100' THEN (SELECT Count(reg_dt) FROM registration WHERE form_creation_user_id = '100'
    and reg_dt = a.reg_dt) END as JOHN,
    CASE WHEN a.FORM_CREATION_USER_ID = '101' THEN (SELECT Count(reg_dt) FROM registration WHERE form_creation_user_id = '101'
    and reg_dt = a.reg_dt) END as JENNY FROM registration a group by a.call_dt,a.FORM_CREATION_USER_ID;

    What needs to be done to fix it?

    Thanks in advance
    J

  2. #2
    Join Date
    Oct 2005
    Posts
    2,557
    This site and about a million others.

    http://mennan.kagitkalem.com/Convert...sInOracle.aspx

Posting Permissions

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