Case and To_Char

Hello

If I want to 'white' in the columns of the Department where there is 0 pay... what additional question should I include and where? (I tried several versions of To_char and I keep getting errors... IE, if in Dept 30 below instead of list 0 will display nothing or empty...

Thank you!


SQL > select job_id JOB,.
2 sum (case when department_id = 30 end of salary otherwise 0) dept30,
3 sum (case when department_id = 60 here end of salary otherwise 0) dept60,
4 sum (case when department_id = 100 where 0 otherwise end of salary) dept100,.
5 sum (case when department_id = 110 here end of salary otherwise 0) dept110,
6 Sum Total_Sal
7 employees
8 job_id group
9.

WORK DEPT30 DEPT60 DEPT100 DEPT110 TOTAL_SAL
---------- ---------- ---------- ---------- ---------- ----------
0 0 0 12000 12000 AC_MGR
0 0 0 8300 8300 AC_ACCOUNT
IT_PROG 0 28800 0 0 28800
ST_MAN 0 0 0 0 36400
0 0 0 0 4400 AD_ASST
11000 0 0 0 11000 PU_MAN
SH_CLERK 0 0 0 0 64300
AD_VP 0 0 0 0 34000
FI_ACCOUNT 0 0 39600 0 39600
FATYTY 0 0 0 0 13000
0 0 0 0 10000 PR_REP

WORK DEPT30 DEPT60 DEPT100 DEPT110 TOTAL_SAL
---------- ---------- ---------- ---------- ---------- ----------
0 0 12000 0 12000 FI_MGR
13900 0 0 0 13900 PU_CLERK
SA_MAN 0 0 0 0 61000
0 0 0 0 6000 MK_REP
AD_PRES 0 0 0 0 24000
0 0 0 0 250500 SA_REP
0 0 0 0 6500 HR_REP
ST_CLERK 0 0 0 0 55700

Change the value to 0 by a NULL value

SQL> ed
Wrote file afiedt.buf

  1  select job_id JOB,
  2         sum(case when department_id = 30
  3                  then salary
  4                  else null
  5               end) dept30,
  6         sum(case when department_id = 60
  7                  then salary
  8                  else null
  9               end) dept60,
 10         sum(case when department_id = 100
 11                  then salary
 12                  else null
 13               end) dept100,
 14         sum(case when department_id = 110
 15                  then salary
 16                  else null
 17               end) dept110,
 18         sum(salary) Total_Sal
 19    from employees
 20*  group by job_id
SQL> /

JOB            DEPT30     DEPT60    DEPT100    DEPT110  TOTAL_SAL
---------- ---------- ---------- ---------- ---------- ----------
IT_PROG                    28800                            28800
AC_MGR                                           12008      12008
AC_ACCOUNT                                        8300       8300
ST_MAN                                                      36400
PU_MAN          11000                                       11000
AD_ASST                                                      4400
AD_VP                                                       34000
SH_CLERK                                                    64300
FI_ACCOUNT                            39600                 39600
FI_MGR                                12008                 12008
PU_CLERK        13900                                       13900
SA_MAN                                                      61000
MK_MAN                                                      13000
PR_REP                                                      10000
AD_PRES                                                     24000
SA_REP                                                     250500
MK_REP                                                       6000
ST_CLERK                                                    55700
HR_REP                                                       6500

19 rows selected.

Justin

Tags: Database

Similar Questions

  • independent research case and accents

    Hello
    I'm new on PL so sorry if it shows with the post :). I'm doing a Research independent of case and accents in the Apex without the help of the upper and lower functions. I found nlssort to solve this problem, but I don't know if I'm doing something wrong or can't do.

    nlssort works very well when it is used like this:
    select *
    from Items_V
    where nlssort(Name,'nls_sort=spanish_ai') like (nlssort(:P5_Name,'nls_sort=spanish_ai'))
    what I also need is results that contain the name and in addition to that a case in the where clause.

    The following code is what I have now and _where I want to include the nlssort_. It returns all the items containing Null values and P5_Name or correspondence.
    select *
    from Items_V
    where  ((Name like (case when to_char(:P5_Sel)='1' then nvl('%'||:P5_Name||'%','%' )
                             else '%' end)
            and Name is not null) 
            or ((case when to_char(:P5_Sel)='1' then nvl('%'||:P5_Name||'%','%' )
                     else '%' end) ='%' and Name is null))                     
    I tried many ways, but I just can't get the right combination and don't really know where to go. Try starting with a simpler approach, I found this concatenation + '%' + nlssort(:P5_Name,'nls_sort=spanish_ai') was not returning items contained, only items that match.


    Thank you in advance,
    Marc

    BTW, I develop on:
    DB 11g
    Request Express 3.1.1.00.09

    a common need for which I have not found another way to solve: independent research case and accents.

    How about smth like (assuming you're on 10g or more):

    SQL>  var p5 varchar2(50)
    
    SQL>  exec :p5 := 'ae'
    PL/SQL procedure successfully completed.
    
    SQL>  with t as
    (
     select 'Âero' str from dual
    )
     select * from t where regexp_like(convert(str,'us7ascii'), convert(:p5,'us7ascii'),'i')
    
    STR
    ----
    Âero
    1 row selected.
    
  • where can I find my id case and repair

    where can I find my id case and repair

    In order to find your Apple ID repair first, go to the Apple device repair status page. Then, enter your case or repair ID in the first field. Then, enter the zip code or serial number in the 2nd field. Finally, click on the submit button. To find your case number go on www. http://supportprofile.Apple.com

  • Cases and protection for iPhone 5 & 5 s fit iPhone SE

    Cases and protection for iPhone 5 & 5 s fit iPhone SE

    Yes.

  • Y at - it a lens which corresponds to Iphone 6 + with case and screen shield attached?

    Does anyone know of a lens wide angle for Iphone 6 + which allows that you keep the protector case and Iphone screen still in place? Most of those I've seen State the case and the shield cannot be still attached.

    Thank you

    As each case and screen protector can be a size and a different shape, I doubt there will be an iPhone lens that could correspond with them on.

  • The new iPhone may use the iPhone accessories 5s as case and battery materials?

    I currently use an iPhone 5, but I plan to move to the new iPhone, however, but to many fans of Apple, I already made an investment in all kinds of accessories.

    I would like to know if I can use cases and boxes of 5s with the new iPhone iPhone battery SE.

    Thank you!

    The specifications indicate that they have the same size. If there is a small difference in the placement of ports and controls that interfere with some cases probably will definitely be confirmed until the launch.

  • I closed and put my computer in its case after use. 3 hours later, when I went to use it again once I took the case and it was hot. It's on and he said "your computer was stopped because of a problem. Anyone had this happen?

    I shut down my computer and put it in its case after use. 3 hours later, when I went to use it again once I took the case and it was hot. It's on and he said "your computer was stopped because of a problem. Anyone had this happen?

    No. I have not experienced this before, after having turned off. It seems that your Mac was not completely extinguished before you he packed. Make sure that it is actually stopped before closing the lid.

  • The case and the smart keyboard will work together on an iPad pro

    The case and the smart keyboard will work together on an iPad pro

    Hi there drew6216,

    Looks like you're wanting to know if the Smart keyboard accessory is compatible with the iPad Pro. Do you mean this product?

    Smart keyboard for iPad Pro

    If so, then Yes, it was made for the iPad Pro. If I misunderstood the question can you please clarify for me a little?

    Thank you for using communities of Apple Support, beware!

  • Calculate the maximum value of the sub-table when creating using a structure of case and records the shift

    I have two 1 d arrays that contain cyclical information (a bit like a sine wave).  One that contains information about the position in degrees and another that contains the couple.  I would like to calculate the value of maximum torque whenever the station is within a certain range (for example, 30 to 80 degrees).  The beaches are repeated - that is why it is cyclical.   I use the function "in the range", a structure of the case and the shift records to build a new table with the values that are included in the beach I said - that was easy part (see attached VI).  I'm struggling with a way to calculate a maximum value for each sub-table formed when the values are 'in range '.   Your help is very appreciated.

    vt92 solution worked!  I agree that there should be a simpler solution, but your to works fine.  Thank you very much.

  • data transmission between the General case and problems of timing instructions using daq devices

    I'm currently developing a program using LabView 2012 SP1.  I am interfacing with an NI USB-6009 data acquisition using NOR-DAQmx 9.5.5f4.  I'm trying to get a voltage on the three analog inputs (AI0 and AI3 AI4) 1 second to start and 20 seconds of starting.  Three digital ports: P0.0, P0.1 and P0.2 are used to market the transistors for the signals in question and must remain high to the course of ~ 20 seconds the readings will take place.  After 20 seconds, I need to take the readings of each analog channel and the difference of the two to determine the delta at the start.  This delta will lead logic to implement later.  The attached VI has a while loop that runs on an interval of 1 second and a case statement that takes a reading DAQ at 1 second and 20 seconds (two separate trials).  The while loop stops after 21 seconds.  The question I have is how to manage the tensions of reading of the second 1 case and the second case 20.  I need to take the difference and the exit to the front after 20 seconds elapsed.  Please keep in mind when you answer that I am relatively new to LabView.  I have experience with several other languages (Matlab script, C, Java, Perl, etc.), but am still learning how to get concrete results in LabView.  That being said, guess I know nothing outside of what you see in this VI.  If you have any recommendations on how to implement more efficiently, I am open to suggestions. Thanks in advance for your help.

    RJ

    I would make the acquisition of 21 seconds of a value of data from data acquisition.  Then, you can index you want specific samples.  Have time to wire samples is much more reliable that Windows hope will be both properly 21 seconds.  It also simplifies the code in a bit.

  • DM4x comes with DM4t label on the box, case, and memory

    I bought a Pavilion model dm4x # LX130AV and received today. Box, case and even the memory of the computer model as a #LX State! 25AV, which is a Pavilion dm4t. I spent hours on the phone w/4 different CS representatives, who have all insisted that the serial number of checks that it is, in fact, a dm4x. I do not understand it being shipped in the wrong box, even the bad case... but the memory? I asked an RMA number and he'll be back. Has anyone else had this experience? Thank you.

    Same question on this topic, see the answer to Matt_Lo

    http://h30434.www3.HP.com/T5/other-notebook-PC-questions/wrong-model/m-p/797299/highlight/false#M28413

    Basically, a dm4x is not a real model number, x is a placeholder to represent a whole subset of models like the dm4t

  • HP ENVY 15 J051EA TS: broken bottom of the case and missing screws

    Hi it screws my low wws lost business and because of this, the hinge is now oushing my case to open. I tried to get another from a different part of the laptopn screw, but it seems that small but which allows the screw stay connected to the case is broken. Long story short, I would need for a new substantive case and a replacement of the screw. Anyone know where I can get these parts?

    Thank you.

    Andreea

    You are welcome

    If you have selected your country and sought the part number, proceeded to purchase and that you are still not able to, I can only assume that the part is not currently available at HP in your area.

  • Get a new case and power supply for my HP Pavilion a6355.uk

    1. sound of the HP Pavilion a6355.uk

    2. Windows 7 Professional 64-bit

    3. no error message

    4. it is not a problem, but its had a new graphics card, new ssd, another hard drive, removed the 500 GB hard drive, and that's all I think.

    Hi, I want to get a new case and power supply for my office

    If I want is http://www.pcworld.co.uk/gbuk/antec-one-0-761345-15970-8-atx-full-tower-pc-case-black-13374257-pdt.h...

    The power I want is http://www.pcworld.co.uk/gbuk/zs650w-uk-zs-series-ocz-zs650w-uk-atx-psu-650w-11342059-pdt.html

    Is 650 Watt most the jury can take? I read somewhere that most can take is 650 watts.

    My only concern is that, how do you take the I/O shield? I've never done before.

    Yes, it will fit your card mother Μatx.

    PS > remember to toggle the toggle SOLVED / SOLUTION to the right of MY post/reply.

  • After the upgrade of Camera Raw 9.1 all cases and objectives profiles have disappeared.  How to make a comeback?

    After the upgrade of Camera Raw 9.1 all cases and objectives profiles have disappeared.  How to make a comeback?  My camera and lens where in there before and worked fine.

    You can see a screenshot of the area of optical Correction to ACR, the list of the brand expanded?

    The ACR and DNG Converter store their profiles in the same folder.  If you have recently uninstalled the DNG Converter, maybe he deleted all of the profiles?  You could put them back by reinstalling the DNG Converter 9.1, which is available on the Adobe updates page:

    Updates

  • Insensitivity to case and cache SQL space

    Hello

    I think that Oracle version 9i go supports case-sensitive hides SQL, i.e. the SQL statements in the cache can match independently of the case and the space. Please can anyone provide an authoritative answer confirming my assertion or makes me in the right direction, where I can verify these facts.

    I look forward to the answers.

    Best regards,

    Best answer is probably a simple demo:

    SQL> delete /*+ find this */ from t1 where owner = 'XXX';
    
    0 rows deleted.
    
    SQL> DELETE /*+ find this */ from t1 where owner = 'XXX';
    
    0 rows deleted.
    
    SQL> delete /*+ find this */ from    t1   where    owner = 'XXX';
    
    0 rows deleted.
    
    SQL> begin
      2  delete /*+ find this */ from t1 where owner = 'XXX';
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL> select sql_id, sql_text from v$sql where sql_text like '%find this%' and sql_text not like '%v$sql%';
    
    SQL_ID
    -------------
    SQL_TEXT
    ------------------------------------------------------------------
    7tc7jtr6jjd5r
    delete /*+ find this */ from t1 where owner = 'XXX'
    
    a4ud12x5fxmnw
    begin delete /*+ find this */ from t1 where owner = 'XXX'; end;
    
    bn65fyws830un
    delete /*+ find this */ from    t1   where    owner = 'XXX'
    
    9dumuwpg5b3ks
    DELETE /*+ find this */ from t1 where owner = 'XXX'
    
    9s7qm0xwcm7sc
    DELETE /*+ find this */ FROM T1 WHERE OWNER = 'XXX'
    
    5 rows selected.
    

    Notes that changes in the case, or the insertion of white space, produces a different SQL_ID, but when I set the static statement in pl/sql in SQL, it gets "normalized" by the PL/SQL engine uppercase without excess white space - may be what you think.

    Concerning

    Jonathan Lewis

    Now on twitter @jloracle

Maybe you are looking for