Question newbie Oracle SQL adding columns to count the contents of the other columns

Greetings,

I do not understand how to integrate charges to my current SQL code that would consist of food and then the elements of the car for each person. Once I understood this concept I want to apply to my real data base (Oracle) where I count medication and problems for each patient.

Using my data of test below, for example the My goal would be to have the number of columns show that Cathy had County 3 foods and an element 1 cars (the County would need to ignore the values zero in these columns). I really don't like if the counter value is repeated in every row for that person.

Select data1. Name, data1. Category, Data1.Results,

Box When data1. IN category ("food") then end FOOD data1.results,

Box When data1. IN category ('Cars') then data1. Results end of CARS

Of

(

Select T1.name name, category null, null results in a_Main T1, a_Food T2 where T1.cpi_seq = T2. CPI_SEQ

UNION

Select T1.name, 'food', T2. Food a_Main T1, a_Food T2 where T1.cpi_seq = T2. CPI_SEQ

UNION

Select T1.name, 'cars', T3. Cars a_Main T1, a_Cars T3 where T1.cpi_seq = T3. CPI_SEQ

) data1

where data1. Category is not null

by name, category

NameCategoryResultsFOODCARS
CathycarsFieroNULL VALUEFiero
CathyfoodSoaking of the pointsSoaking of the pointsNULL VALUE
CathyfoodScoopScoopNULL VALUE
CathyfoodSoftServeSoftServeNULL VALUE
DavecarsFirebirdNULL VALUEFirebird
DavecarsGremlinNULL VALUEGremlin
DavecarsTransportNULL VALUETransport
DavecarsVegaNULL VALUEVega
DavefoodCount ChoculaCount ChoculaNULL VALUE
DavefoodDonutsDonutsNULL VALUE
DavefoodLittle retardedLittle retardedNULL VALUE
DavefoodPizzaPizzaNULL VALUE
MarycarsTaurusNULL VALUETaurus
MaryfoodBird seedBird seedNULL VALUE
MikecarsHondaNULL VALUEHonda
MikecarsJeepNULL VALUEJeep
MikefoodBurgerBurgerNULL VALUE
MikefoodFriesFriesNULL VALUE
MikefoodFoamFoamNULL VALUE
SuecarsPintoNULL VALUEPinto
SuecarsTaurusNULL VALUETaurus
SuefoodHumusHumusNULL VALUE
SuefoodKabooliKabooliNULL VALUE

Select data1. Name, data1. Category, Data1.Results,

Box When data1. IN category ("food") then end FOOD data1.results,

Box When data1. IN category ('Cars') then data1. Results end of CARS,

Count (*) over (partition t1.name, data1. NTC category),

Of

(

Another way would be

Select

..

de)

all

)

Group

name

Category

order by

name

Category

Depends on your needs (for example, the final projection).

Tags: Database

Similar Questions

  • 2 newbie question on Oracle SQL Developer

    Hello world

    I just started using SQL Developer (1.5.1), the question can seem easier (can not find FAQ...), any help will be appreciated.

    1. How can I turn on result of the query grid, not clear?
    2. How can I see the retail package compile error message in SQL Developer?


    Thank you!

    Lei

    Hello

    In fact, you can look at it SQL Dev demo.
    1. run the query using F9 or CTRL + ENTER.
    2 If you look on the underside of the SQL Dev, there is a dockable panel (Log - compiler tab) that shows you the warning message, error, etc.

    Kind regards

    Buntoro

  • Remove the carriage returns in the text in an oracle SQL table column

    Hello

    Someone knows how to remove carriage returns in a text column in an Oracle table
    using SQL. So far, I have:

    Replace (text_field, Chr (13),' ')


    but this is ignored.

    (We use db 10g (enterprise Edition Release 10.2.0.4.0) and SQL * more 10.2.0.1.0)

    I would be very grateful for any help.

    -Mark

    How does the following:

    UPDATE table_name SET col_name = REPLACE (col_name, Chr (13), ");

    But if your new line is CR + LF, then use REPLACE (col_name, Chr (13) + Chr (10), ")

  • Oracle SQL Developer - how to display the date with TIME

    OK I change the setting of the NLS to DD-MON-RR HH.MI. SS
    (Tools-> Preferences-> database-> parameter NLS)

    BTW - what is changing the format of the database or just my client side? I don't want to change the database and other users would be affected by my change.


    I check the date time poster by practice
    SELECT double TO_CHAR(SYSDATE + 1, 'DD-MON-YYYY HH:MI:SS');

    Returns
    JUNE 24, 2009 10:32:55

    OK, here is my problem or question...
    but I wan't do in East... I have a column in a table that stores a number of minutes from a given date...
    the given date is 12/30/1899 00:00:00

    If I want to display the minutes in a format of date and time... but when I do
    Select To_TIMESTAMP (30 December 1899 00:00:00 "," mm/dd/yyyy HH24:MI:SS) + (Start_Moment) / 1440.
    To_Date (30 December 1899 00:00:00 "," mm/dd/yyyy HH24:MI:SS) + (Stop_Moment) / 1440
    from tableA

    RESULTS
    22 JUNE 09 23 JUNE 09

    I tried the function TO_CHAR but don't have time to be like
    Select TO_CHAR (to_date('12/30/1899 00:00:00', 'mm/dd/yyyy HH24:MI:SS') + 57580140 / 1440) double

    RESULTS
    22 JUNE 09

    I don't know that it's the simple convert function that I do not know...

    Mark as answer?

  • Oracle/wss_username_token_client_policy adding not token in the soap header

    Hello

    I'll call an external web service (external reference) of bpel in a version of the composite application 11.1.1.7, service I call you requires ws-security usernametoken and is accessible by https, I joined oracle/wss_username_token_client_policy and oracle/log_policy policy so I can see the whole of the SOAP message, (I also did the configuration of basic.credentials and I tried with the oracle.webservices.auth.password and oracle.webservices.auth.username properties too without success). The problem is that the soap request message sent by bpel does not put the username and password in the header, all I can see in the soap header is as follows:

    < env:Header > < wsa: to > https://myserver:7000 / GC3Services/IntXmlService/call < / wsa: to > < process of wsa: action > < / wsa: action > < wsa: MessageID > urn: 0CF65DF0F8AD11E38F787D1F1907427F < / wsa: MessageID > < wsa: RelatesTo > urn: 0CF65DF0F8AD11E38F787D1F1907427F < / wsa: RelatesTo > < wsa: ReplyTo > < wsa:Address > http://www.w3.org/2005/08/addressing/anonymous " < / wsa:Address > < ReferenceParameters, such > < instra:tracking.ecid xmlns:instra = ' http://xmlns. Oracle.com/SCA/Tracking/1.0 "> 11d1def534ea1be0:5514321:146b552a766:-8000-000000000000cb45 < /instra:tracking.ecid > < xmlns:instra = instra:tracking.conversationId ' http://xmlns. Oracle.com/SCA/Tracking/1.0 ' > urn: 0CF65DF0F8AD11E38F787D1F1907427F < /instra:tracking.conversationId > < instra:tracking.parentComponentInstanceId = xmlns:instra ' http://xmlns. Oracle.com/SCA/Tracking/1.0 ' > Reference: 20010 < /instra:tracking.parentComponentInstanceId > < instra:tracking.compositeInstanceCreatedTime = xmlns:instra ' http://xmlns. Oracle.com/SCA/Tracking/1.0 "> 2014-06-20T 11: 59:40.808 - 07:00 < /instra:tracking.compositeInstanceCreatedTime > < / ReferenceParameters, such > < / wsa: ReplyTo > < FaultTo > < wsa:Address > http://www.w3.org/2005/08/Addressing/Anonymous < / wsa:Address > < ReferenceParameters, such > < = xmlns:instra instra:tracking.ecid ' http://xmlns. Oracle.com/SCA/Tracking/1.0 "> 11d1def534ea1be0:5514321:146b552a766:-8000-000000000000cb45 < /instra:tracking.ecid > < xmlns:instra = instra:tracking.conversationId ' http://xmlns. Oracle.com/SCA/Tracking/1.0 ' > urn: 0CF65DF0F8AD11E38F787D1F1907427F < /instra:tracking.conversationId > < instra:tracking.parentComponentInstanceId = xmlns:instra ' http://xmlns. Oracle.com/SCA/Tracking/1.0 ' > Reference: 20010 < /instra:tracking.parentComponentInstanceId > < instra:tracking.compositeInstanceCreatedTime = xmlns:instra ' http://xmlns. Oracle.com/SCA/Tracking/1.0 "> 2014-06-20T 11: 59:40.808 - 07:00 < /instra:tracking.compositeInstanceCreatedTime > < / ReferenceParameters, such > < / FaultTo > < / env:Header > .

    I don't know why bpel does not send the user name and password if oracle/wss_username_token_client_policy policy is enabled (I also tried with politics oracle/wss_username_token_over_ssl_client_policy without success).

    Thank you

    Carlos.

    The problem has been the oracle/log_policy policy because it shows not all of the SOAP message, the oracle/log_policy policy hides the security part (which I think is a weird behavior).

  • Functional test Oracle Forms: adding new row in the Table

    Hello

    I try to create a Test Script for creating order sale to R12.  I use OpenScript Version: 12.5.0.1 Build 287

    I am able to create the script for all orders with less than 9 lines.

    Currently, it has more than 8 lines, the script does not work. The threshold is unable to find the object to line 9.

    "//forms:textField [(@name ='LINE_ORDERED_ITEM_DSP_" + getVar ("{{setLine}}") + "" ")] .

    The reason could be, when I scroll down to line 9 in the form, I guess the name of the textfield object is changed.

    If everyone faced the similar problem, please throw some light on this.

    Thank you

    Guna.

    Hi Guna,

    You will need to provide the "maxvisiblelines" for the part of lines to BBA. This must be done at the component level. When you define a component itself, you must specify the value for maxvisiblelines

    Thank you

    Anand

  • Releases of question on 2 separate, one for Playbook and the other for BB10

    Hello

    At the moment we have an application that is currently enabled for BB10 and Playbook. However, we've recently re-written the application take over much better phone interface, and we would like to submit a version that is not specific to BB10 and have a separate for Playbook version.

    What I hope we can do is just uncheck the BB10 of the current version and let the Playbook checked, then submit a new version with only selected BB10. However, I wasn't sure if this overwrite the version of the Playbook and pull it store since the release "more recent" doesn't have the verified Playbook. Is it possible to have these 2 releases by-side, but be in the same "application"?

    Thank you
    Jake

    It works as you expect it. In fact you don't have to uncheck the BB10 phones on the old version.

  • "Explain Plan" in Oracle SQL Developer is grayed out

    Hi all

    I know that this is not the right place for this post, but I look around and do not know where to post questions about Oracle SQL Developer - I assume that this tool is also discussed here in this forum.

    My question is very simple (I guess):
    1. I installed Oracle SQL Developer 3.0.04.
    2. I have added a new DB connection to a database that is hosted in one of my servers in the local network.
    3. However, when I write some SQL queries, I intend to use the feature 'Explain the Plan', but it is grayed out (disabled).
    4. How can I activate this return?

    Hello

    {forum: id = 260}

    Concerning
    Marcus

  • PL/SQL error ORA-00904 not no projection in Oracle SQL Developer

    Hello

    I am new to Oracle and the different development tools available.
    Using Oracle SQL Developer, we encountered a scenario where a PL/SQL package doesn't compile, but it only displays the warnings in the log of the compiler.

    The packeage even when it is compiled using PL/SQL Navigator shows a much more detailed list of errors and highlights the real problem.

    Why Oracle SQL Developer does not show the following error?

    PL/SQL: ORA-00904: "SERIAL_LINE_ID": invalid identifier




    Concerning
    Adrian

    There are various settings that you can give to messages. (for example, information, warning, severe).

    Tools-PL/SQL compiler options.

    Normally, just the first 20 messages are displayed.
    Change the code to get rid of the warning messages or change settings to ignore the information and warning messages.

    P.S. There is a dedicated forum sqldeveloper where your question should really be displayed.

    Published by: Keith Jamieson on March 9, 2009 13:45

  • Oracle SQL Developer in JDeveloper data modeling

    Hello

    See http://www.oracle.com/technology/products/database/sql_developer/files/Modeling.html
    Oracle SQL Developer - early release of the adoptive parent 2 data modeling
    Oracle SQL Developer data modeling is the latest product offering to join the Oracle database tools. SQL Developer data modeling offers complete data and database, modeling, tools and utilities, including entity-relationship, modeling relational (configuration database), Type data and multidimensional modeling, front and rear complete engineering and code generation. It includes the import to and the export to a variety of sources and targets, offers a variety of formatting options and valid models through a predefined set of design rules.

    SQL Developer data modeling can connect to any version of the data base Oracle 9.2.0.1 and later versions, and is platform-independent. Initially available as a standalone product, with the future versions available as an extension of Oracle SQL Developer. The second version of the early adopter has stand-alone and file-based.


    See the screenshots, import.png, multi.png, notation.png, subview.png, erd.png, largemodel.jpg

    question
    These data new modeling capabilities are destined to end up in a future version of JDeveloper (replacing the existing data modeling features in JDeveloper)?

    Thank you very much
    Jan Vervecken

    N °

    Modeling of SQL Developer focuses on ER diagrams and a repository - which we think is targeting a different audience, then the 'physical' offered by JDeveloper modeling.

  • Error 17002 i/o in Oracle SQL Developer

    Hello

    I am trying to connect to the database to test using the Oracle SQL developer, but I get the below error
    IO error: the network adapter could not establish the connection provider code 17002

    I used to connect to the test server very well 2 weeks ago (the test server is on a different network and I connect using VPN).

    I am able to connect to the database of the Production by the developer Oracle SQL (without VPN) but when I try to connect to the test, I get the error.

    I checked the name of the service and the ports and everything is fine and. So, what could be the problem?

    Is there any change that's happened?
    Check firewall settings

  • Oracle SQL Developer with SQL Developer Data Modeler

    Friends,

    I'm trying to understand the differences between Oracle SQL Developer Data Modeler and the possibility to use the SQL Developer Data Modeler.

    I have looked at two home pages produced on OTN, http://www.oracle.com/technology/products/database/datamodeler/index.html & http://www.oracle.com/technology/products/database/sql_developer/index.html and would appreciate your comments on my findings so far

    (1) the Oracle SQL Developer Data Modeler is a paid product stand-a-lone while using the Data Modeler of SQL Developer feature is free

    (2) the Data Modeler in SQL Developer functionality is basically a "viewer" I create my existing table of DR. by dragging in the Modeler in the object browser, but that's all. I can't save the diagram for later use or use to change the structure of the or the tables

    (3) if I need to have 'Oracle Designer' as ERD capability so I need to use Oracle SQL Developer Data Modeler (after purchase!)

    (4) are there other differences that I missed?


    Thanks in advance

    Yes, you've nailed it!

    Have fun
    K.

  • Problem connecting to Oracle SQL Developer

    Hi all

    I am trying to connect to the database from the remote computer through Oracle SQL Developer, it gives me the following error.

    Status: Faliure-Test failed: connection/o: the network adapter could not establish the connection.

    I had given the host name as the name assigned to this server, it did not work.

    Later, I tried with the IP address of the server, it worked.

    Can someone tell me how I can connect by giving the hostname instead of IP address.

    Thanks in advance,
    Vinay

    Hi Vinay,

    One way would be to add an entry in your hosts file. On windoze, you can find it in

    %SystemRoot%\System32\Drivers\Etc

    Concerning
    Peter

  • Oracle SQL Developer Data Modeler start error

    Hi all

    I just downloaded Oracle SQL Developer Data Modeling (2.0.0.57.0) [released July 1, 2009] by selecting the option ' Oracle SQL Developer Data Modeler for Windows (this zip file contains the JRE).

    After that I installed the same and tried to start clicking on datamodeler.exe, I get the following error message

    "Failed to create an instance of the JVM on the path:... \jdk\jre\bin\client\jvm.dll.

    On the same machine, I can successfully run the SQL Oracle program without error. My machine is having Windows XP Professional SP3.

    Any ideas? If there is a problem with Java, that of the Oracle SQL Developer should also not run. But as I said it runs with any error, but the Oracle SQL Developer Data Modeler gives the above error.

    Kind regards

    JAA149

    Hey Jawad,

    you wrote you have 960 MB of RAM - how did you do a test with 1.5 MB of RAM and 2 MB of RAM?
    No doubt this is a problem of memory - memory change in the datamodeler.conf file option:
    -There 'AddVMOption-Xmx768M"by default; to take
    -"AddVMOption-Xmx512M" or never, making it suitable for your configuration - you can check the available free memory first.

    Philippe

  • How to count the number of columns in an oracle table using sql

    How to count the number of columns in an oracle table using sql

    You must put the name of the table in capital letters

    As

    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    
    or
    
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');
    

    Concerning
    Arun

Maybe you are looking for