Results 1 to 2 of 2

Thread: Select Query

  1. #1
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200

    Unanswered: Select Query

    I have a table with 2 fields,user and status.the data is like:

    amen A
    alen A
    Alex R
    alex1 P
    Alex2 S
    alex3 S

    I wana get a querry so it returns the values as:

    A R P S Total
    2 1 1 2 6

    I want to get the Sum of each status and Sum total of all status together

    mickykt

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Select Query

    Originally posted by mickykt
    I have a table with 2 fields,user and status.the data is like:

    amen A
    alen A
    Alex R
    alex1 P
    Alex2 S
    alex3 S

    I wana get a querry so it returns the values as:

    A R P S Total
    2 1 1 2 6

    I want to get the Sum of each status and Sum total of all status together

    mickykt
    select sum(decode(status,'A',1,0)) a
    , sum(decode(status,'R',1,0)) r
    , sum(decode(status,'P',1,0)) p
    , sum(decode(status,'S',1,0)) s
    , count(*) Total
    from mytable;

Posting Permissions

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