How can I replace column value with a particular value in SQL

Hi All,
Can anyone please tell me how can I format my output with replacing a column value with a specific value which actually depends on the present value of the column
I am executing the following SQL statement
select state,count(id) from <table_name> where composite_dn= <composite_dn_name> group by state;
My Present output is:
State No.Of Instance
1 3
3 28
I want to replace the value in the column state as follows
State No.OfInstances
Completed 3
Faulted 28
I want "1" to be reppaced by "Completed" and "3" to be replaced by "Faulted"
Is is possible with SQL or PL/SQL , if it is then how can I achieve this required result. Please help!!
Thanks in Advance!!
Edited by: Roshni Shankar on Oct 27, 2012 12:38 AM

Hi Roshni,
I guess this CASE clause can be simulated by a DECODE and also it is very easy to use.
Refer -- http://www.techonthenet.com/oracle/functions/decode.php
select decode(t1.state,t2.state_id,t2.state_name), t1.count_id
from <table_2> t2, (select state,count(id) count_id
from <table_name>
where composite_dn= <composite_dn_name>
group by state) t1
where t1.state = t2.state_id;HTH
Ranit B.
Edited by: ranit B on Oct 27, 2012 2:02 PM
-- link added
Edited by: ranit B on Oct 27, 2012 2:19 PM
-- sample code added

Similar Messages

  • How can I replace the Portal with completely new Flash website?

    Can I replace the Portal with completely new Flash website? My customer do not want the JSP UI. Instead, he wants a completely new designed Flash site. Is it possible to do it? How can I deploy a new portal to cover the current one?

    If you have a look at some of the code examples which do the equivalent of site maps, you could in theory replace the whole portal desktop with some sort of Flash framework which reads the user's role structure at run time.
    I think it is useful to remember that the SAP portal is primarily a business application launchpad. It does that very well. Trying to make it into a Flash launchpad will be challenging.

  • How can I replace iCloud contacts with up-to-date contacts on my Macmini?

    Originally I used iCloud when it first was released. My contacts went into the cloud.  I stopped using iCloud and maintained my Contacts on my Macmini. All of my up-to-date information which includes additional contacts and revisions are on the Mac mini.  iCloud wants to work with my old information but I'd rather replace the information on iCloud with the information on my computer.  How can I replace what's in iCloud with my edited and updated information?

    Open Address Book on your Mac, click All Contacts, select a single contact, press Command-A to select them all (they should all be highlightes), then go to File>Export>Export vCard and save this on your desktop.  Then delete all your iCloud contacts by going to icloud.com on your computer, log into your iCloud account and open Contacts, click on All Contacts, to the right click on any single contact to select it, click on the gear-shaped icon at the bottom left and choose Select All, then press the Delete key on your keyboard to delete them all.  Then click on the gear-shaped icon again, choose Import vCard and navigate to the vCard you saved earlier to import your contacts to iCloud.

  • How Can I Export A Table With Its Entries ( values )

    Hi guys,
    How can i export a table with the entries that the table is populated with ??!!
    Best Regards,
    Fateh

    To export a table and its data you can do it a number of ways.. Do you have access to SQL Developer? If not you can do it through the APEX SQL Workshop..
    Under SQL Workshop, Utilities, Data Unload, To text (or XML, whichever you are more comfortable with..).. Select your schema, click next button, select the table, click next, select the columns you want exported (select ALL ITEMS in the select List), click next, on optionally enclosed by I usually enter a " (Sometimes I have long strings in columns), click the include column names checkbox to get the column names at the top of the document, click unload data button..
    To get the ddl (code to build table) Sql Workshop, utilities, generate ddl, create script, select schema, select next, click table checkbox, select next, click the checkbox of table you want to get ddl for...
    Thank you,
    Tony Miller
    Webster, TX
    There are two kinds of pedestrians -- the quick and the dead.
    If this question is answered, please mark the thread as closed and assign points where earned..

  • How can i replace column name using reciever JDBC adapter on runtime.

    Hi Experts,
    I have a problem with reciever JDBC synario.
    Target Oracle table has columns named 2 bytes Japanese character like "日本".
    Datatype cannot accept 2bytes character as element name.
    So, I would like to how to replace column name on runtime.
    Please tell me.
    Regards,
    Shinya Kawaoge

    Hi Shinya Kawagoe,
    I understand there is a column with two Japanese characters in target database table. Now you want to UPDATE or INSERT data in that table. You do not want to rename the column name in the database table (if you want to rename column, ask the target database admin ).
    As Japanese characters are not allowed in XML Data Type in ESR. You can [Define a SQL_QUERY Statement|http://help.sap.com/saphelp_nwpi711/helpdata/en/44/7b7855fde93673e10000000a114a6b/frameset.htm]. Check the Addres日本s in below code.
    <root>
      <stmt>
        <Customers action="SQL_DML">
          <access> UPDATE Customers SET CompanyName=u2019$NAME$u2019, Addresu65E5u672Cs=u2019$ADDRESS$' WHERE CustomerID='$KEYFIELD$u2019
          </access>
          <key>
            <NAME>Firma</NAME>
            <ADDRESS>Strasse 3 </ADDRESS>
            <KEYFIELD>FI</KEYFIELD>
          </key>
        </Customers>
      </stmt>
    </root>
    Regards,
    Raghu_Vamsee

  • How can I build a table with the time values of a timer from a while loop

    Hi:
    I have a question concerning building a table:
    Every 100ms I read a value from a sensor (while loop with a timer). I would like to build a table with the actual time and the concerning value. For example:
    0msec         1V
    100msec     2V
    200msec     3V
    300msec     4V
    etc.
    If I use the Express VI for building a table, I always get the date and time, but I don't need the date and the time is in the following format: HH:MMS, which is nonsensical for me as I can't differentiate within msec. Can I change the format anywhere?
    Can I also save the table to a file or even to an Excelsheet? How can I do that?
    Thanks for your help!

    Hi Craig:
    thank you very much. To solve the mystery : ) :
    I want to drive a stepper motor with a specific frequency. To get the current degree value of the motor I would like to measure the current time (from the beginning of the move on). (With a formula I get the degree value out of the time)
    Concurrently I would like to get data from a torque sensor and from a pressure sensor. That's why I asked you about the time and the table. The measurement should start with the movement of the motor. How can I do that? Right now I have different block diagrams (different while loops) (see attachment) and I would like to put them in one.
    I haven't done the block diagram for the pressure sensor yet, so there is only the one for the torque sensor and the one for the motor.
    I also would like to set a mark in the table when the voltage value of an analog input gets under a specific threshold value. Is that possible?
    I'm sorry, I'm a novice in LabVIEW. But maybe you can help me.
    Thank you very much!
    Steffi
    Attachments:
    motor.vi ‏238 KB
    sensor.vi ‏59 KB

  • How can I replace a color with a pattern fill?

    Hi everyone, thanks for any responses in advance!
    I've created quite a detailed design that works with 4 pixels per cm and 16 colors, canvas size 120x170cm. I'm wanting to replace all of a single color with a pattern, is there a way to do this?
    I can replace a color with another flat color by using adjustments etc... but I want to fill the entire of one color area with a pattern instead. The only way I can think to do this would be to use the magic wand tool to select every pixel of the same color, then create a new layer and overlay with a fill of the desired pattern, however as the design is so detailed it would take me an awful long time to select each color!
    Can anyone suggest a quicker more efficiant way to do this?
    Thanks!

    Select --> Color Range
    Mylenium

  • How can you replace v.25 with an earlier version, say v.23 for my business purposes?

    How can I install an earlier MAC Version of Firefox, e.g. 23 or earlier ? and then Uninstall the latest Version 25?
    According to the Health Insurer I charge for services, Version 25 cannot work for them.

    Best is to use the latest Firefox release for browsing on the internet and install an older version alongside that uses its own profile.
    See this article about how to install multiple versions on Mac OS X:
    * http://www.businessinsider.com/how-to-run-firefox-4-and-3-simultaneously-in-mac-os-x-with-multiple-firefox-profiles-2011-3
    *https://support.mozilla.org/kb/Managing+profiles

  • How can i replace original media with newly transcoded optimised media in the timeline?

    I have transcoded new optimised media (Prores 422) after importing and partly editing some original Canon H.264 material. I now want to replace the original H.264 edit with the matching new pro res 422 clips so I can playback more smoothly on a MBPro. I can't find a menu command in FCP X to allow me to do this other than during the initial import process. But it does allow you to create transcoded material after the initial import; how do you link/replace to it?

    Welcome to one great feature of FCP X: what you are asking for is not needed. It is done for you automatically.
    When you have selected "original or optimized media" selected in your preferences, FCP X will use optimized media if available, or original media if you haven't transcoded. So really there is no step 3 :-)

  • How can I get column totals with group breaks

    We manually generate a report of file groups and their associated data files each day for each of our databases.
    For each database we take data from dbcc showfilestats and assemble it into an Excel spreadsheet (see below).
    I would like to use a SQL job to generate the reports (results do not need to be in Excel format). I can insert the data from the DBCC into a table; but, I'm stuck on how to write a select statement that will break on file group and provide column totals.
    I've been looking at group by; but, I don't see how to make it work.
    Suggestions?
    FileGroup
    FileID
    Volume
    Allocated(MB)
    Used space(MB) 
    Free space(MB)
    Used %
    1
    1
    Data1
    100
    50
    50
    50%
    1
    15
    Data2
    200
    175
    125
    87.50%
    1
    21
    Data3
    300
    200
    100
    6.60%
                600
    425
    275
    70.80%
    FileGroup
    FileID
    Volume
    Allocated(MB)
    Used space(MB) 
    Free space(MB)
    Used %
    2
    1
    index1
    100
    50
    50
    50%
    2
    15
    index2
    200
    175
    125
    87.50%
    2
    21
    index3
    300
    200
    100
    6.60%
    600
    425
    275
    70.80%

    Take a look at the following blog on subtotal, total & grand total:
    http://www.sqlusa.com/bestpractices2005/subtotaltotalgrandtotal/
    It appears that you need only 1 level of totals.
    BOL:
    Summarizing Data Using ROLLUP
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How can I find the element with the closest value to a calculated "target value" in a 1D array?

    Hello all,
    may be the following question is very simple, but I am relatively new in labview and it would be great if somebody could help me:
    I have a acquaried 1D array of data-points. Now, I have to find the element in this array which value is the closest to a calculated "target value".
    After finding the element with the value close to the "target value", I have to get the position of this element (i.e. the index) in the 1D array.
    Now, I have to use this index to find and extract the element at this position in an other 1D array.
    It would be very nice if somebody could help me with this problem.
    Thank you,
    beam

    Find attached a sample vi that you can modify.
    Attachments:
    select_target_value.vi ‏22 KB

  • How can I replace navigation buttons with obvious ones?

    Here's the web page:  http://josephskibell.com/. I've just taken over this website for a friend and opened it in Dreamweaver but the code is such that the existing four little square navigation buttons at the top of the page don't show up in design view (these change the book images).  The client wanted some more "obvious" buttons there because people are not understanding that those little squares are buttons.  Arrows may work better.  Can anyone advise?
    thanks

    Open scroll_buttons.css.
    The image sprite used is here:
    http://josephskibell.com/images/navigator.png
    My advice is to make a bigger sprite and change height and width sizes in your CSS code.
    More on CSS Sprites.
    http://alt-web.com/DEMOS/CSS-Sprites.shtml
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • How can I populate a UILabel with an Integer value?

    I have a UILabel field and I want to display an integer value in this field.
    I used lblTemp.text = @"number of apples"; this worked for string only. But now I have an TempInt integer whose value I want to put into the lblTemp.text.
    my final label field should be "number of apples is <TempInt>"
    Any suggestions on the syntax to do this?
    thanks for the help,
    Max

    [NSString stringWithFormat:@"%d", tempInt]

  • How can i replace a blank with a space

    i wanna take a string and place spaces between each letter but leaving the origional spaces
    how would i do something like this
    (ex. input: my name is sam
    exput: m y n a m e i s s a m )

    i suggest you read the damned tuts. your questions are pitifully simple. a simple search (see that search field on the right?) will answer every question you've asked. it doesn't seem as if you have experimented one bit.
    problem
    ask for help
    new problem
    ask for help
    new problem
    ask for help
    i think i see a pattern. it says you are stupid and lazy and are afraid to experiment or try to learn on your own.

  • How Can I replace newScale Text Strings with Custom Values?

    How Can I replace newScale Text Strings with Custom Values?
    How can I replace newScale text strings with custom values?
    All  newScale text is customizable. Follow the procedure below to change the  value of any text string that appears in RequestCenter online pages.
    Procedure
    1. Find out the String ID of the text string you would like to overwrite by turning on the String ID display:
    a) Navigate to the RequestCenter.ear/config directory.
    b) Open the newscale.properties file and add the following name-value pair at the end of the file:res.format=2
    c) Save the file.
    d) Repeat steps b and c for the RmiConfig.prop and RequestCenter.prop files.
    e) Stop and restart the RequestCenter service.
    f) Log  in to RequestCenter and browse to the page that has the text you want  to overwrite. In front of the text you will now see the String ID.
    g) Note down the String ID's you want to change.
    2. Navigate to the directory: /RequestCenter.ear/RequestCenter.war/WEB-INF/classes/com/newscale/bfw.
    3. Create the following sub-directory: res/resources
    4. Create the following empty text files in the directory you just created:
    RequestCenter_0.properties
    RequestCenter_1.properties
    RequestCenter_2.properties
    RequestCenter_3.properties
    RequestCenter_4.properties
    RequestCenter_5.properties
    RequestCenter_6.properties
    RequestCenter_7.properties
    5. Add the custom text strings to the appropriate  RequestCenter_<Number>.properties file in the following manner  (name-value pair) StringID=YourCustomTextString
    Example: The StringID for "Available Work" in ServiceManager is 699.
    If you wanted to change "Available Work" to "General Inbox", you  would add the following line to the RequestCenter_0.properties file
         699=General Inbox
    Strings are divided into the following files, based on their numeric ID:
    Strings are divided into the following files, based on their numeric ID:
    String ID  File Name
    0 to 999 -> RequestCenter_0.properties
    1000 to 1999 -> RequestCenter_1.properties
    2000 to 2999 -> RequestCenter_2.properties
    3000 to 3999 -> RequestCenter_3.properties
    4000 to 4999 -> RequestCenter_4.properties
    5000 to 5999 -> RequestCenter_5.properties
    6000 to 6999 -> RequestCenter_6.properties
    7000 to 7999 -> RequestCenter_7.properties
    6. Turn off the String ID display by removing (or commenting out) the line "res.format=2" from the newscale.properties, RequestCenter.prop and RmiConfig.prop files
    7. Restart RequestCenter.
    Your customized text should be displayed.

    I've recently come across this information and it was very helpful in changing some of the inline text.
    However, one place that seemed out of reach with this method was the three main buttons on an "Order" page.  Specifically the "Add & Review Order" button was confusing some of our users.
    Through the use of JavaScript we were able to modify the label of this button.  We placed JS in the footer.html file that changes the value of the butt

Maybe you are looking for