Using the account with pivot for several columns

create table TEST_CASETBL (ID, NUM, TYPE, CREATED_BY, CREATED_DT) that choose

1, 1-1, CO, ABC, sysdate-10 of all the DOUBLE select union

2, 1-1, EO, ABC, sysdate-10 of all the DOUBLE select union

3, 1-2, CO, ABC, sysdate-10 of all the DOUBLE select union

4, 1-2, UPD, ABC, sysdate-10 of all the DOUBLE select union

5, 1-3, CO, XYZ, sysdate-10 of all the DOUBLE select union

6, 1-3, EO, XYZ, sysdate-10 of all the DOUBLE select union

7, 1-4, CO, XYZ, sysdate-10 of all the DOUBLE select union

8, 1-4, NT, XYZ, sysdate-10 of all the DOUBLE select union

9, 1-5, EO, XYZ, sysdate-10 of all the DOUBLE select union

10, 1-5, NT, XYZ, 10 sysdate from DUAL;

I want to calculate number of NUM, County of different values in the 'TYPE' column based on the CREATED_BY column

Expected result:

CREATED_BY Count (NUM) Count (CO) Count (EO) Count (s) Count (UPD)

ABC                                 2(which means 1-1,1-2)               2                   1                         0            1

XYZ                           3(which means 1-3,1-4,1-5)               2                    2                        2            0

Please provide your suggestions to solve the SQL query form

Thank you

Hello

Melissacharlier-Oracle wrote:

create table TEST_CASETBL (ID, NUM, TYPE, CREATED_BY, CREATED_DT) that choose

1, 1-1, CO, ABC, sysdate-10 of all the DOUBLE select union

2, 1-1, EO, ABC, sysdate-10 of all the DOUBLE select union

3, 1-2, CO, ABC, sysdate-10 of all the DOUBLE select union

4, 1-2, UPD, ABC, sysdate-10 of all the DOUBLE select union

5, 1-3, CO, XYZ, sysdate-10 of all the DOUBLE select union

6, 1-3, EO, XYZ, sysdate-10 of all the DOUBLE select union

7, 1-4, CO, XYZ, sysdate-10 of all the DOUBLE select union

8, 1-4, NT, XYZ, sysdate-10 of all the DOUBLE select union

9, 1-5, EO, XYZ, sysdate-10 of all the DOUBLE select union

10, 1-5, NT, XYZ, 10 sysdate from DUAL;

I want to calculate number of NUM, County of different values in the 'TYPE' column based on the CREATED_BY column

Expected result:

CREATED_BY Count (NUM) Count (CO) Count (EO) Count (s) Count (UPD)

ABC                                 2(which means 1-1,1-2)               2                   1                         0            1

XYZ                           3(which means 1-3,1-4,1-5)               2                    2                        2            0

Please provide your suggestions to solve the SQL query form

Thank you

This CREATE TABLE statement works when try you it?  Do you need single quotes around string literals?

You may want something like:

WITH data_to_pivot AS

(

SELECT created_by, type

COUNT (DISTINCT num) over (PARTITION BY created_by) AS count_num

OF test_casetbl

)

SELECT *.

OF data_to_pivot

PIVOT (COUNT (*)

TO indicate the ("CO" AS count_co

'EO' AS count_eo

'NT' AS count_nt

'UPD' AS count_upd

)

)

ORDER BY created_by

;

Tags: Database

Similar Questions

  • Using the oracle same House for several database (configuration database)

    Hi guys,.



    I saw a few shops use the same Oracle_home to Multiple Instances of the database...



    Basically, they install binaries 11G or 10G once for example: /u01/app/oracle/product/10.2



    For the following database facilities they do not install the binaries... they just point the new home of the oracle database to what they currently have...



    for example



    cat/etc/oratab



    newdb:/U01/app/Oracle/product/10.2





    So I was wondering if someone could give me the right steps to do this or a metalink note...



    Thanks in advance



    Here's what I think below:



    Step 1

    Enter the new name of the database in/etc/oratab... pointing right oracle_home as below



    Step 2



    Use DBCA or scripts to create the new db



    Please, please provide the right steps or metalink note

    user569403 wrote:
    Hi guys,.

    I saw a few shops use the same Oracle_home to Multiple Instances of the database...

    Basically, they install binaries 11G or 10G once for example: /u01/app/oracle/product/10.2

    For the following database facilities they do not install the binaries... they just point the new home of the oracle database to what they currently have...

    for example

    cat/etc/oratab

    newdb:/U01/app/Oracle/product/10.2

    So I was wondering if someone could give me the right steps to do this or a metalink note...

    Thanks in advance

    Here's what I think below:

    Step 1

    Enter the new name of the database in/etc/oratab... pointing right oracle_home as below

    Step 2

    Use DBCA or scripts to create the new db

    Please, please provide the right steps or metalink note

    You cannot create a database without using the binaries already installed in an ORACLE_HOME. However, all THE databases are created in an existing OH. No matter if you have one or a hundred ORACLE_HOMEs, the procedure is the same:

    1 - set ORACLE_HOME, ORACLE_SID and path suitable for the new db. Of course, if you only have a single ORACLE_HOME, you would choose it. If you have more than one, you choose the one you think is appropriate for this new db.
    .
    2. create the db. You can use dbca, or connect to an idle instance and run scripts that you saved for this purpose. DBCA is a very good and very practical tool, but is not required. It's use is come with a few caveats.

    3 - update the oratab accordingly, if you wish (I always thought). Do you understand how and when oratab is used, and why I say update ' If you see is '?

  • How to: using the same control panel for several vi and reproducing change to the control panel.

    I created a labview project that contains about 40 vi.  Each vi has a joint control panel which is a group of ip address, or address of the port and the parameters that are passed high-level vi at low level vi for the purpose of control and access our daq cards.  As this control panel exists in all the vi and must not be the same there is a problem when the need to make a change or update the controls during development.  The problem is how long it takes to go and change the control panel of each single vi.  I wish I had a way of reproducing a change in the Panel of control through all six simultaneously.

    All controls in the control panel are in a bundle, so all values are passed to 1 thread.

    I tried to turn the Panel in a sub vi and this way I can just "create control" and have output parameters maniuplate vi, but if I update the vi, I still have to go back and create a new control for each vi under the control has changed.

    I tried using secondary and the creation of the control panel in a sub vi which is displayed in the secondary, but gives the undesirable consequence of not being able to view or change the settings of the control panel if the program does not work, as pristine as when sub-panels program does not work.

    Is there a another way to display the front panel of a Subvi next using a panel of void?  Is there a better way to propagate changes in a bundle in a series of vi?

    Yes a def type might help you and I would take the next step to make a strict type def if you want the look to be the same on all its bodies. You can also view this nugget on Type definitions for more idea about it.

    Have fun

    Ben

  • I bought the PC Version of Fable III of this year early and installed and created an account with games for windows Live!

    I bought the PC Version of Fable III of this year early and installed and created an account with games for windows Live! About 2 months ago, I formatted my computer and reloaded windows 7! Last night I downloaded Microsoft Flight and used my existing account to play! Today, I installed Fable III and the game won't start as it says that I am not connected to the internet! This is wrong since I write here for you! Why my game will not, organize that I have connected to my account last night with problem now? Please help me?

    Yes, unfortunately GFWL's an imperfect system. Steam has similar problems. I find the best way to avoid
    problems is to play all the games that are related to a system off line.
    I have absolutely no interest in what GFWL can offer online, in any case.
    Many games have a "fix" for GFWL, which are generally easy to find through a search.
    Of course these only help facilitate offside line.

    Try Timeslips Fable 3 GFWL remover - it is well known in the modding community, particularly
    its managers mod for Bethesda games and his job is safe to use.

    http://Timeslip.users.sourceforge.NET/

    .

  • Is it safe to use Safe Mod with networking for the use of the computer every day?

    Hi, my computer has problems to start normally and I was wondering, is it safe to use Safe Mod with networking for the use of the computer every day? I use the computer like 10 hours + every day. Is this correct and safe? Thank you

    Hello, Winston,

    It is actually for troubleshooting only.

    Networking Mode safe mode starts Windows in mode safe mode and includes the network drivers and services needed to access the Internet or other computers on your network.

    Some applications may not work properly or not at all if you use safe mode with networking for everyday computing.

    Wireless network adapter may not work when you use the Option "Safe Mode with network.

    http://support.Microsoft.com/kb/305616

    Safe mode disables most of the processes and services running. These services include the Windows Update service. »

  • When I try to use the webcam with Skype it blocks Skype and said "Skype has stopped working, windows is checking for a solution."

    Original title: lifecam 3000 and Skype does not?

    Hello, I tried the two 5.5 beta and 5.3. When I try to use the webcam with Skype it blocks Skype and says "Skype has stopped working windows is checking for a solution." I have windows update connection bars 4/5 drivers and my computer ==> http://www.newegg.com/Product/Product.aspx?Item=N82E16883103361 help is appreciated, thanks

    Hello, I had just fixed yesterday. I deleted the drivers and programs that accompanies it, it ends up being the lifecam software that comes with it interfering with Skype, thanks to all who help :)

  • Upgrade to 8.1 fails "you must use an account with administrator privileges to install Windows 8.1." "Try loggin with the user of an administrator on this PC account and try the update again.

    Hello

    I have some difficulties to try to upgrade to windows 8... The computer asked me to go to 8.1, I click OK and it sends me to the store. Then I click on "Download Windows 8.1 Pro" and I get the message:
    "You must use an account with administrator privileges to install Windows 8.1." Try loggin with the user of an administrator on this PC account and retry the update", as shown in the attached picture.

    The thing is that I am the only administrator account.
    I also checked enable the built-in Administrator, by logging in and trying to here, but from the account built-in administrator is not aloud me to use Store.

    What can I do? Thank you

    Original title: upgrade Windows 8 Pro x 64 to Windows 8.1

    Hello

    I've read reports that uninstalling Windows Update KB2871389, and then put it back solves the problem.

    I read recently that this Fix - It might help...

    http://support.Microsoft.com/kb/971058/en-us

  • I brought an old Sidewinder Precision Pro joystick for use with old Microsoft Flight Sim 2000 Edition Pro, I can use the joystick with my Vista Home Premium laptop

    I installed Microsoft Flight Simulator 2000 Professional Edition, on my laptop. I bought an old Microsoft Sidewinder Precision Pro joystick. Can I use the joystick with my Vista Home Premium OS?.

    Hello

     
    What is the model of the sidewinder Precision Joystick?
     
    You can use it with Vista, but sometimes it can cause a problem. Check the link and if you have a problem follow the steps in the article.
    You experience problems when you use a Sidewinder Force Feedback Pro joystick with Flight Simulator on a Windows 2000, Windows XP, or Windows Vista-based computer
    http://support.Microsoft.com/kb/294672
  • best way to avoid the full table scan for clause "column is zero.

    I have a query with is control null, and because of that it performs a total scan of table (in millions of rows in the table)

    SELECT id, x,
    LAG (id) OVER (PARTITION BY userid ORDER BY has had place, id) as p_id,.
    FROM MyTable
    WHERE X is ZERO


    What is the best way for me to avoid the full table scan. I have indexes for the X column and other columns.

    Thank you

    Hi Vasif

    NULL values are indexed if the indexed entry also includes a value non-zero.

    If you create an index such as:

    CREATE INDEX mytable_x_idx ON mytable (x, ' ');

    ensure all null values for the column X are indexed and will therefore potentially use the index to search for null values, assuming of course the result set is small enough to justify the use of the index in your query.

    I have spoken previously on my blog:

    http://richardfoote.WordPress.com/2008/01/23/indexing-nulls-empty-spaces/

    See you soon

    Richard Foote
    http://richardfoote.WordPress.com/

  • Rotation of the photos in iPhoto I could simply use the trackpad with 2 fingers turning motion.  In pictures, it seems that I have to use the Edit menu, etc etc?

    In iPhoto, I could simply use the trackpad with 2 fingers rotating motion to change photos quickly to stand.  In the Photos but it seems I have to use the Edit menu, etc. etc.?

    command + r or command + option + r, depending on the direction you want.

    Also, right-click on the image to the same command, hold the option for the choice

  • 4 is not compatible with the protection of the identity of simple past on my HP using the player with the tips of the fingers. How can I make it work? IE9 works very well. Should I stop using FireFox?

    I have a HP DV7-4165 which has Windows 7 64 bit and simple features of the HP pass identity protection using the drive with the tips of the fingers. My Firefox support says "If you have the Firefox browser on your computer when your HP SimplePass Identity Protection software is installed, a Firefox extension will also be installed which enables support for the use of the fingerprints with the browser Firefox." Once I updated to Firefox 4 it no longer works.

    You can get Firefox 3.6.16 here:

    http://www.Mozilla.com/en-us/Firefox/all-older.html

  • Satellite A300 - how to use the recovery with external DVD drive disc?

    Hello

    I bought a toshiba Satellite A300 - 15 d

    FTM the tsscorp drive that is installed in the camera no longer works (does not detect any type of media what so ever). ) need to recover the laptop, so I used a USB DVD drive to boot from the restore disc, but after that the charges of recovery console it says waiting for media in the f: drive, which is the tsscorp drive although I used an external drive to load the disc.

    What files should I edit to make it to load from the drive externally and if this isn't the solution, what do I do?

    Thanks in advance

    Hey Buddy,

    Unfortunately I think that it of not possible to use the recovery with external CD/DVD drive disc. Therefore, place the internal for use the recovery disc.
    You can get a new drive to an authorized service provider.

    But if the original OS from Toshiba is installed, you can use the function of disk recovery HARD reinstall Windows as well. Go to the advanced boot menu (F8) and select Repair my computer :)

  • After the upgrade to El Capitan, I get "the scanner is attributed to ImageCapture. Using the scanner with TWAIN? What to say?

    I have XP Epson-610 and have scanned on it successfully for years. To date, but when tried to open I get the ap scanner, the scanner is attributed to ImageCapture. Using the scanner with TWAIN? ImageCapture does not work on El Capitan? What is TWAIN, a printer-scanner driver?

    Thank you.

    TWAIN is an old scanner interface. OS X now use ICA, Architecture (?) of Capture of Image.

    Never seen this message, but I guess that means Capture of Image is using the scanner, or is configured to use the scanner and it is not necessary for the third party software. You open picture Capture, or did the scanning software provided with the scanner by Epson?

  • I already have one zero drive for FCP 7 projects implemented.  I would use the same scratch drive for FCP 10.  Is there a special way of implementation is seamless?

    Said to implement the scratch disc so I can use the same hard drive for FCP 7 and 10 projects - something on a folder separated for 10 projects.  What are the steps to do t his?

    More details would be useful. You have already imported media in FCP7? Or you are just starting to work with both applications at the same time? What application you plan to use to ingest media? Don't try to use them both for ingest.  You can set FCPX to use the FCP7 Capture Scratch location for your support and then let the media imported in place. You can also assign a location for media to import using FCPX and then use this location for FCP7, again leaving the media in place.

    Or I totally misunderstood and you only talking about using the same drive, which is not a problem at all.

  • Startup Repair:-using Skype, can I use the method of selection for me starts better what should I suggest? Thank you pp

    Startup Repair:-using Skype, can I use the method of selection for me starts better what should I suggest? Thank you pp

    Hello

    Welcome to Microsoft Vista Forum community!

    Please answer the following questions to help you better about it
    ·         What is the edition of Vista installed on the computer?
    ·         You try to make the Windows Vista startup repair?
    ·         How long have you used Skype for?
    ·         Are you facing problems starting with windows after downloading Skype?

    If you encounter problems with Windows startup after downloading Skype, then you can try to disable the startup of Skype at Windows startup. (For example, in MSN, go to tools > Options > General > do not start when Windows starts.)

    For more information, you can consult the help of Skype: https://support.skype.com/

    Hope this information is useful.
    Let me know if it worked.
    All the best!

    Concerning

    Jeremy K
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

Maybe you are looking for