PIVOT Function in isqlPlus ???  HELP please!

I need to Pivot a column of Numeric data in a table.
The data is as follows: (I generate this table in a VIEW):
COL1 COL2 COL3
jdoe green -1
jdoe blue -1
jdoe yellow 0
jdoe red 0
jdoe orange -1
asmith blue 0
asmith green -1
asmith gold 0
asmith yellow -1
asmith red -1
asmith orange 0
I produce this table of data from a VIEW select statement.
I am writing a second VIEW select as a subquery to this top query. I want the second or subquery VIEW select to produce a PIVOT of the third column that will produce the following for me:
COL1 COL2 COL3 COL4
jdoe 5 3 2
asmith 6 3 3
...the end result being one row for each username with a breakout of total count of -1's and total count of 0's, and of course a grand total in Col2.
I cannot find any sensible documentation in the miles and miles of documentation within Oracle's library. Can anyone help me please?

select col1
, count(*) col2
, sum(decode(col3,-1,1,0)) col3
, sum(decode(col3,0,1,0)) col4
from your_table
group by col1

Similar Messages

  • Can't find IPad 2 video camera function anymore.  Help please.

    It seems that one of the updates along the way resulted in video camera record disappearing.  Still camera function works.  Do it need to reset everything or what?  FaceTime works well.

    Yes, as I said, do NOT tap, you must swipe between the different modes for camera, either swipe on the words themselves or in the center of the screen.

  • Applying function to graph, help please..!

    Hey Guys, 
    I am very new to LabView and do not even know how do I construct the question but I´ll explain it here.
    I am using LabView 8.5 combined with UV-Vis spectrometer to take the readings of absorption against time of a reaction mixture. The reaction continues for 48 hours. What I want to do is, 'at the completion of the reaction, the absorbance graph will become constant. As the absorbance becomes constant, I want the program to swtich on a pump which will push a reagent into the reaction pot containg the reaction mixture and then continue taking reading of absorbance´.. Is it clear ? Is there a way to do so ? I mean how to tell the LabView that as the absorbance becomes constant, switch on the pump while continuing measuring absorbance?
    I shall highly appreciate any help.
    Thank you.
     

    What you need to do is to define how much variation in absorbance readings over some period of time is considered "constant." There will always be some noise and possibly drift in the measurements, so you cannot reasonably expect to have, say, ten consecutive identical readings.
    One way to do this is to take the last group of readings (where you decide how many are in the group), do a linear regression on the readings, and define "constant" as the absolute value of the slope less than some threshold. This tends to take the noise out and may be fairly sensitive to small changes in the slope.
    Lynn

  • How do I watch my iTunes movies, tv shows on my mac without having to download them all to my HD?  I really want my Mac to function like my Apple TV since I have just moved and don't have my TV for another few weeks. Help please?

    How do I watch my iTunes movies, tv shows on my mac without having to download them all to my HD?  I really want my Mac to function like my Apple TV since I have just moved and don't have my TV for another few weeks. Since I purchased my three Apple TV. I have had no need to download any of my movies to my Mac.  Which has been great.  However, I remember that I used to now have to do this... or did I?  I am just frustrated because I want to stream all this stuff vice haveing to waiting for it all to download fill up my Mac's HD and then just delete. Someone help please?

    Play the movie in iTunes to stream it.
    Click the cloud icon to download it.

  • I've downloaded the newest version of softwear to my iTunes libary (iOS 10.5 i believe) iTunes store now dosn't function right and i'm not able to sync. my iPod 4G with my libary. i've tried to reinstall iTunes, but for no use. help please.

    I've downloaded the newest version of softwear to my iTunes libary (iOS 10.5 i believe) iTunes store now dosn't function right and i'm not able to sync. my iPod 4G with my libary. i've tried to reinstall iTunes, but for no use. help please.

    well i have to be honest, but i don't know if it the vista you use has any significance for this. but you can try.
    okay follow:
    1: click "start" on the status line on the buttom of your screen.
    2: then click on "all Programs" and find "Accessories" and find the "command prompt"
    3: Right click with your mouse "command prompt" and click on "run as administrator"
    (as you has click'd on "run as administrator", "command prompt" should appear.)
    4: when it appears you need to type this "netsh windsock reset"
    5: wait for your computer to registrer the command you gave it, and restart your computer.
    then erverything should be pretty much as good or better then new.

  • I need serious help please.. We do translations of schoolbooks, I looked for an over-type function but were unable to find, we are working in indesign CS 5. it takes up allot of time to delete text and type in the new language.

    I need serious help please.. We do translations of schoolbooks, I looked for an over-type function but were unable to find, we are working in indesign CS 5. it takes up allot of time to delete text and type in the new language.

    Argh that's frustrating! I never noticed that key did not work in InDesign.
    A bit of research and it turns out the MS Office has this as an option in their software. But I cannot find an option in InDesign preferences to make this work.
    However, somethings are not listed in the shortcuts and preferences and are hidden triggers in InDesign which can be accessed through a script.
    I'm not saying it's possible to activate the Insert Key through a script, but it's plausible that it can be activated.
    Maybe ask on the scripting forum? InDesign Scripting
    I know this may be a possibility as with InDesign's earlier versions of PDF export to interactive documents there previously was no way to export interactive pdfs as single pages if in Spreads.
    But the option to toggle this setting was scriptable.

  • How can I uninstall Maverick and reinstall snow leopard? My mac hasn't been the same since I upgrading to maverick. Runs slow, crashes, can't cope with normal functions.... Help, please help

    How can I uninstall Maverick and reinstall snow leopard?
    My mac hasn't been the same since I upgrading to maverick. Runs slow, crashes, can't cope with normal functions....
    I need to go back to leopard or buy a new MacBook Pro!
    Help, please help

    Revert to a Previous OS X
    Revert to former OS from Mavericks
    Revert to Snow Leopard

  • Hi. I have downloaded the new iOS 6.0 software update but now I can't switch off the shuffle function when playing music. Help please. Stuart

    Hi. I have downloaded the new iOS 6.0 software update but now I can't switch off the shuffle function when playing music. Help please. Stuart

    I have the same problem and haven't been able to figure it out either

  • Double Click Functionality - Help Please

    Hi,
    In ControlPanel >> Mouse Properties >> there is an option for increasing the double click speed.
    Similarly , i need to have a JSlider , getting User Input from the JSilder Object, thereby increasing the double click speed for my Swing Application.
    how to do this one in swing ???
    Help please....
    Thanks,
    Mani

    Windows tells java how fast the clicks were. To change this property in java gets very confusing, because you will need to time the interval between clicks since I don't think you can change this system setting from your program. It is far easier to just stay with the double click speed set by windows.

  • Pivot function in Oracle 10g???

    Hello everybody,
    at the beginning of the week I had a simple problem (I thought that...), but now after trying and trying, I can't find a solution for it. First of all I'm working on Oracle 10g with the version 10.2.0.4.0. I can't change the version, it's standard in the whole company...
    At the beginning I have a table like the following one, but please note, that the compartment, the type and the amount are flexible and can change at any time:
    comp type amount
    a1 6280 10
    a2 6280 20
    a2 4810 15
    a2 1147 12
    a3 6280 33
    Now I want the table to look like this:
    a1 a2 a3
    1147 0 12 0
    4810 0 15 0
    6280 10 20 33
    A simple question in Excel for example, I just use the pivot function and have it fixed within 10seconds. But how can I do sth. like this in Oracle with simple SQL? Or it can be PL/SQL too, cause I will use this in an APEX application.
    Can you please give me a hint or a solution? But as stated before a1, a2, a3 are just examples it is possible that tomorrow a4, a5 and so on are coming. If it is necessary I can also create additional tables and views of course!
    Thanks for your help!
    Regards
    hoge

    Hi Hoge!
    Here is your solution:
    SELECT TYPE,
           sum(a1) AS a1,
           sum(a2) AS a2,
           sum(a3) AS a3
      FROM (SELECT TYPE,
                   decode(comp, 'a1', amount, 0) AS a1,
                   decode(comp, 'a2', amount, 0) AS a2,
                   decode(comp, 'a3', amount, 0) AS a3
              FROM test)
      GROUP BY TYPE
      ORDER BY TYPE; And here is my test case setup:
    CREATE TABLE test
        (comp VARCHAR2(255),
         TYPE NUMBER,
         amount NUMBER);
    INSERT INTO test(comp, TYPE, amount) VALUES('a1', 6280, 10);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 6280, 20);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 4810, 15);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 1147, 12);
    INSERT INTO test(comp, TYPE, amount) VALUES('a3', 6280, 33);
    commit;Best regards,
    Matt

  • How to use Pivot function for group range in oracle SQL

    Hi,
    Good Morning !!!
    I need to show the data in the below format. There is 2 columns 1 is State and another one is rate.
    State     <100     100-199     200-299     300-399     400-499     500-599     600-699     700-799     800-899     900-999     >=1000     Total
    AK     1     2     0     4     1     4     4     35     35     4     1     25
    AL     0     0     2     27     10     17     35     2     2     35     0     103
    AR     0     0     1     0     0     2     2     13     13     2     0     6
    AZ     0     1     2     14     2     14     13     3     3     13     0     57
    CA     0     0     1     6     2     7     3     4     4     3     0     34
    Developed the below query but unable to use the range on pivot function . Please help on this.
    (select      (SELECT SHORT_DESCRIPTION
         FROM CODE_VALUES
         WHERE CODE_TYPE_CODE = ad.STATE_TYPE_IND_CODE
         AND VALUE = ad.STATE_CODE
         ) STATE,
    nr.rate
         FROM neutrals n,
         contacts c,
         addresses ad,
         xref_contacts_addresses xca,
         neutral_rates nr
                        where n.contact_id=c.contact_id
                        and n.address_id = ad.address_id
                        and xca.address_id=ad.address_id
                        and xca.contact_id=c.contact_id
                        and nr.contact_id = n.contact_id
                        and nr.rate_frequency='HOUR' )

    user8564931 wrote:
    This solutions is useful and Thanks for your reply.
    How can i get the Min value and Max value for each row ?
    State     <100     100-199     200-299     300-399     400-499     500-599     600-699     700-799     800-899     900-999     >=1000     Total     Min     Max
    IL     0     0     1     5     1     5     40     1     1     40     0     53     $10     $2,500
    IN     0     0     0     0     0     0     1     49     49     1     0     3     $70     $1,500This?
    WITH t AS
            (SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 67 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 23 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 78 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 34 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 4 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 15 VALUE FROM DUAL
             UNION ALL
             SELECT 'AZ' state, 6 VALUE FROM DUAL
             UNION ALL
             SELECT 'AZ' state, 123 VALUE FROM DUAL
             UNION ALL
             SELECT 'AZ' state, 123 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 23 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 120 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 456 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 11 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 24 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 34 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 87 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 23 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 234 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 789 VALUE FROM DUAL
             UNION ALL
             SELECT 'MH' state, 54321 VALUE FROM DUAL),
         -- End of test data
         t1 AS
            (  SELECT state,
                      NVL (COUNT (DECODE (VALUE, 0, 0)), 0) "<100",
                      NVL (COUNT (DECODE (VALUE, 1, 1)), 0) "100-199",
                      NVL (COUNT (DECODE (VALUE, 2, 2)), 0) "200-299",
                      NVL (COUNT (DECODE (VALUE, 3, 3)), 0) "300-399",
                      NVL (COUNT (DECODE (VALUE, 4, 4)), 0) "400-499",
                      NVL (COUNT (DECODE (VALUE, 5, 5)), 0) "500-599",
                      NVL (COUNT (DECODE (VALUE, 6, 6)), 0) "600-699",
                      NVL (COUNT (DECODE (VALUE, 7, 7)), 0) "700-799",
                      NVL (COUNT (DECODE (VALUE, 8, 8)), 0) "800-899",
                      NVL (COUNT (DECODE (VALUE, 9, 9)), 0) "900-999",
                      NVL (COUNT (DECODE (VALUE, 10, 10)), 0) ">=1000"
                 FROM (SELECT state,
                              CASE
                                 WHEN VALUE < 100 THEN 0
                                 WHEN VALUE BETWEEN 100 AND 199 THEN 1
                                 WHEN VALUE BETWEEN 200 AND 299 THEN 2
                                 WHEN VALUE BETWEEN 300 AND 399 THEN 3
                                 WHEN VALUE BETWEEN 400 AND 499 THEN 4
                                 WHEN VALUE BETWEEN 500 AND 599 THEN 5
                                 WHEN VALUE BETWEEN 600 AND 699 THEN 6
                                 WHEN VALUE BETWEEN 700 AND 799 THEN 7
                                 WHEN VALUE BETWEEN 800 AND 899 THEN 8
                                 WHEN VALUE BETWEEN 900 AND 999 THEN 9
                                 WHEN VALUE >= 1000 THEN 10
                              END
                                 VALUE
                         FROM t)
             GROUP BY state)
    SELECT STATE,
           "<100",
           "100-199",
           "200-299",
           "300-399",
           "400-499",
           "500-599",
           "600-699",
           "700-799",
           "800-899",
           "900-999",
           ">=1000",
             "<100"
           + "100-199"
           + "200-299"
           + "300-399"
           + "400-499"
           + "500-599"
           + "600-699"
           + "700-799"
           + "800-899"
           + "900-999"
           + ">=1000"
              total,
         least("<100",
           "100-199",
           "200-299",
           "300-399",
           "400-499",
           "500-599",
           "600-699",
           "700-799",
           "800-899",
           "900-999",
           ">=1000") min_val,
          greatest("<100",
           "100-199",
           "200-299",
           "300-399",
           "400-499",
           "500-599",
           "600-699",
           "700-799",
           "800-899",
           "900-999",
           ">=1000") max_val
      FROM t1
    /

  • Pivot function problem

    Hi all,
    In pivot function "in" clause i want to use sql query, because i want to take values dynamically from the table.
    How can i use, is there any solution for that.
    Pls help me.
    mani

    Here's what I was thinking:
    SQL> DECLARE
      2   yrno NUMBER;
      3   x    VARCHAR2(100) := '''direct'' AS Store, ''online'' AS Internet';
      4  BEGIN
      5    SELECT year
      6    INTO yrno
      7    FROM
      8    (SELECT EXTRACT(YEAR FROM order_date) year, order_mode, order_total FROM orders)
      9    PIVOT
    10    (SUM(order_total) FOR order_mode IN (x))
    11    WHERE rownum = 1;
    12 
    13    dbms_output.put_line(yrno);
    14  END;
    15  /
      (SUM(order_total) FOR order_mode IN (x))
    ERROR at line 10:
    ORA-06550: line 10, column 40:
    PL/SQL: ORA-56901: non-constant expression is not allowed for pivot|unpivot values
    ORA-06550: line 5, column 3:
    PL/SQL: SQL Statement ignoredWith the value of "x" easily created dynamically. Now all I can say is:
    Ouch ... I've been taken out to the woodshed and beaten.
    I am sending in an enhancement request for version 12.
    If you agree that this is something we need please log onto metalink and do so too. Thank you.

  • Ever since I updated to the IOS 6, I no longer can play my music in the car!  It is plug and play!  It just sits there saying connecting and nothing happens.  A few of my friends have said the same thing.  Help please!  Any ideas?

    Ever since I updated to the IOS 6, I no longer can play my music in the car!  It is plug and play!  It just sits there saying connecting and nothing happens.  A couple of my friends have said the same thing.  Any ideas?  Help please!

    Hello ..do you have a history on the phone? did you get it wet? was it dropped? have you been using an authentic ORIGINAL apple charging cable?
    this problem occurs when there is a short circuit  in the phone... you  most likely got  it wet at some point and maybe didnt even realize it? The moisture in the phone hasb probablly  oxidized one or several capacitors, integrated chips thereby short circuiting the phone. that is why he phone  is acting erratic because these short circuits inadvertently "activates" other circuits.. eventually the phone will not turn on anymore- the heat will stress the citcuit board and you will have discontinuity along your main power lines and the phone will cease to function..i see this alllll the time in our shop
    the fact you upgraded to ios6 will even work the phone harder because its a more powerful operating system taking full advantage of the A4 chip..

  • My Macbookpro has turned into microsoft windows and lost all data, how do I recover it with my windows 7 still inside? I accidentally install directly, Help please...

    My Macbookpro has turned into microsoft windows and lost all data, how do I recover it with my windows 7 still inside? I accidentally install directly, Help please...

    ok turn it off manually and turn it back on while holding the apple logo bottor or the function botton this will give you  an option to choose if you want to startup with osx ow windows. let me know if this works
    <Email Edited By Host>

  • Apple Wireless Keyboard - Shift + 'r' key not working. It doesn't capitalise the letter. Can someone help please. Thank you.

    Hi all,
    I am having some problem with the Apple Wireless Keyboard. It has not problem connecting to both my iPad mini / iPhone 4S.
    The problem comes when I start to type with it. All the keys are functioning will, except when I am trying to capitalise the letter 'r'.
    I tried using Shift + r. It doesn't work, regardless whether I use the left or right Shift key.
    Any someone help please. Thank you.

    If your Macbook is less than a year old, it is under warranty. A repair of of a problem of this kind would be free. So, if you have a warranty, have the problem fixed by Apple.
    If your Macbook is more than one year old, please tell us what operating system you are running, and any other information that would help understand what is going on.
    If you do get the keyboard to work for a short time, long enough to post back, please unlock the "caps lock" button.

Maybe you are looking for