How to give a number of groups using Group by?

Hi guys,.

For example

----------------------------------------

Something like that:

SQL > select decode (grouping (ename),

2 0, ' '|| Ename |', salary: ' | SAL,

3 "dept". DEPTNO |': ' | Count (*): ' employees, the total wages: ' | Sum (SAL) data)

4 of PEM

Group by rollup (deptno, (ename, sal)) 5

6 have grouping (deptno) = 0

7 order of deptno, decode (grouping (ename), 1, ' ', ename)

8.

DATA

---------------------------------------------------------------------------------------------------

total 10:3 employees, Dept of wages: 8750

CLARK, salary: 2450

KING, salary: 5000

MILLER, salary: 1300

Department 20:5 employees, total wages: 10875

ADAMS, salary: 1100

FORD, salary: 3000

JONES, salary: 2975

SCOTT, salary: 3000

SMITH, salary: 800

Total 30: 6 employees, Dept of wages: 9400

ALLEN, wages: 1600

BLAKE, salary: 2850

JAMES, salary: 950

MARTIN, salary: 1250

TURNER, salary: 1500

WARD, salary: 1250

------------------------------

How can I do


total 10:3 employees, Dept of wages: 8750, Grp1



CLARK, salary: 2450



KING, salary: 5000



MILLER, salary: 1300



Department 20:5 employees, total wages: 10875, Grp2



ADAMS, salary: 1100



FORD, salary: 3000



JONES, salary: 2975



SCOTT, salary: 3000



SMITH, salary: 800



Total 30: 6 employees, Dept of wages: 9400 Grp3



ALLEN, wages: 1600



BLAKE, salary: 2850



JAMES, salary: 950



MARTIN, salary: 1250



TURNER, salary: 1500



WARD, salary: 1250




ALLEN, wages: 1600



BLAKE, salary: 2850



JAMES, salary: 950



MARTIN, salary: 1250



TURNER, salary: 1500



WARD, salary: 1250
----------------------

Kind regards
Noob

Hello

Instead of

decode(deptno,10,'Grp1',20,
  'Grp2',30,'Grp3')) data

You can say:

'Grp' || DENSE_RANK () OVER (ORDER BY deptno)     AS data

Tags: Database

Similar Questions

  • How to give rownumber for each group

    Hai All

    I use the function group to separate and in this group, I need to give rownumber to each departure of members of Group 1 and when a group is on the needs in number to start new 1


    For example

    There are 3 Department and it is separated by the function of group by Department and here I need to give the line number. And the line number must be separated for each group

    Thanks and greetings

    Srikkanth.M

    How about using...

    ROW_NUMBER() OVER (partition by GROUP order by X)
    

    If this is not the case, how about post you some sample data and the output you want from these data.

    In addition, your version of Oracle

    select * from v$version;
    
  • SQL Help: How to collect summary number in group by?


    Hello

    I have the following table:

    create table tb_class_info (classNbr number (5), number (2) of ClassType, classTeacherNbr number (4));

    insert into tb_class_info values (101, 1, 12);

    insert into tb_class_info values (001, 2, 12);

    insert into tb_class_info_values (001, 2, 13);

    insert into tb_class_info_values (002, 2, 12);

    insert into tb_class_info_values (002, 2, 12);

    I would like to get statistics on the cnt, cnt for classType = 2 classTeacherNbr classNbr. I expect to have the following results:

    classNbr classType2Cnt classTeacherCnt

    101                0                         0

    001                2                          2

    002                2                          1

    The following SQL code I use:

    SELECT classNbr,

    SUM (CASE when classType = 2 THEN 1 ELSE END 0) as classTypeCnt,

    SUM (CASE when classType = 2 SO unique classTeacherNbr ELSE 0 END) as classTeacherCnt

    OF tb_class_info

    GROUP BY classNbr;

    However, I have the ' ORA-00905: lack of keyword ' error. Any suggestion on this subject?

    Thanks for your help!

    Select classnbr

    sum (case when classtype = 2 then 1 end)

    , count (distinct case when classtype = 2 then teachernbr end)

    of tb_class_into

    Classnbr group;

  • How to give rownum for each group in forms6i

    Hai All

    I have to use the line for each individual group number if it is possible in oracle forms6i

    I used this feature and get an error, the function is

    ROW_NUMBER() over (partition by bar code, order by code bardate bar)


    and if it is possible to use decode function in oracle forms6i

    Thanks for giving good solutions

    Thanks and greetings

    Srikkanth.M

    Same question but different title :)

    Yes, you can use function in 6i to decode

    Bangoura
    [My Oracle Blog | http://baigsorcl.blogspot.com/]

  • How to count the number of edges using counters SMU-6363

    Hello

    I'm counting the number of edges in a test signal in a duration of 50 Ms I use the SMU-6363 map and connect to the TRC test signals 0 SRC (PFI 8). Is that a correct connection? What else do I need hardware wise be a correct set for this application?

    Thank you

    Jeet

    Hi Jeet,

    This configuration is correct. Hardware wise, that's all you need to do.

    Kind regards

    Jorge Fernandez
    Technical sales engineer
    National Instruments
    ____________________________________________
    Certified LabVIEW Associate Developer (CLAD)

  • How to limit the number of printers can be installed on this computer by using Group Policy?

    How to limit the number of printers can be installed on this computer by using Group Policy?

    Hello

    Thanks for asking! If I understand correctly, you should limit the printers installed on the computer by using Group Policy. I suggest you follow the troubleshooting steps to check if this may help.

    The question you have posted is related to Technet and would be better suited to the Technet community. Please visit the link below to find a community that will provide the best support.
    http://social.technet.Microsoft.com/forums/en-us/category/WindowsServer

  • How to get the frame number current timeline using jsx?

    How to get the frame number current timeline using jsx?

    Thanks for the link!

    Clarification: I was looking for the current image on the timeline of the video. OP he mentions that he had found how to get that so I searched a bit more and found this thread: Re: can I inpoint in read/write and out-point of the clips in a group of video with scripts? They have the following functions, I have not tried yet, but it seems like it should work.

    function getCurrentFrame() {}

    try {}

    Var ref = new ActionReference();

    ref.putProperty (charIDToTypeID ('Rprp'), stringIDToTypeID ('currentFrame'));

    ref.putClass (stringIDToTypeID ('timeline'));

    var / / desc = new ActionDescriptor();

    desc.putReference (charIDToTypeID ('null'), ref);

    var TC = executeAction (charIDToTypeID ('getd'), desc, DialogModes.NO);

    Return TC.getInteger (stringIDToTypeID ('currentFrame'));

    } catch (e) {return null ;}

    };

  • Serial number already in use message - what gives?

    I have lightroom 6. Installed on my laptop. Works very well. I had upgraded LR 5 on this same laptop computer. I'm also 5 LR on a desktop imac. Same license - worked fine when I created this on LR 5. So, after getting a new camera GX8, I also wanted to upgrade my imac to the same configuration of LR 6 I on the laptop because otherwise the raw files of Pana GX8 simply do not work.

    Thought that this worked well on LR 5, so witi LR 6 upgrade process. The upgrade actually worked well, but the "Adobe Application Manager" appears at the same time one "the xxx serial number is already used by the maximum number of computers. You must disable another computer within 30 days... "message.

    Sigh... Give me a break. The best license I can read it says that I can use on my desk and a macbook pro. It's not like I can use them at the same time. It's just me. Only two eyes/hands. I use the product under license. How to get out of this mess? Unfortunately, the pop-up message gives no idea how to solve. Lightroom is sometimes such a PITA.

    Now what? Anyone?

    don't use do not CC. Or rather, at some point I installed CC on the laptop (to 6) but then licensed the download of LR 6 entirely perpetually. So I don't use CC do not have it on the imac.

    I contacted the customer care chat - what they did got me over the hump and it works now. Sweet. The pleasure with support chat is safe.

  • How to give a full permission to system32 using the registry

    Hello...

    go to this link below

    http://www.powercomars.com/docs/powercom_vista_and_office_2007_compatibility/how_to_set_windows_system32_permission_in_vista.htm

    you will find how to give permission to the system32 folder, I do this work steps very well, but I need to do the foregoing even using the registry is possible?

    How to using the registry.. ?

    Thank you

    If I understand your question, wondering how to edit the registry to change the permissions on the System32 folder.

    File permissions are not stored in the registry, so this cannot be accomplished.

    The other way to change file permissions using the takeown and icalcs commands.

    http://TechNet.Microsoft.com/en-us/library/cc753024 (WS.10) .aspx

    http://TechNet.Microsoft.com/en-us/library/cc753525 (WS.10) .aspx

  • I recently used a dvd + rw disk to back up my photos. Now when I put a dvd in my pc, why it will not display on the screen that's all there is, or how to give me access to it?

    I recently used a dvd + rw disk to back up my photos. Now when I put a dvd in my pc, why it will not display on the screen that's all there is, or how to give me access to it?

    Depends on what you used for the backup.

    If you used the windows backup or another backup software will contain the entire disk will be a backup file, and view/use this file, you use the same software that allows you to save.

  • My old laptop is dying. When I tried to install Photoshop elements 7 on my new laptop, he told me that the serial number is not valid. It's the same number that I used before. What gives?

    My old laptop is dying. When I tried to install Photoshop elements 7 on my new laptop, he told me that the serial number is not valid. It's the same number that I used before. What gives

    I think that this program is covered in the link below

    CS2 (or earlier version) activation server has disappeared, then read below

    You MUST use the special version and the serial number on the page, not your original drive or serial number

    l http://helpx.adobe.com/x-productkb/Policy-Pricing/Creative-Suite-2-activation-end-Life.htm

    NOTE that CS2 will not install on a Mac "modern", and when you install the special version of the PPro2 on a Win7 or Win8 or Win10 computer, you may need to right click on the program icon and select Windows XP compatibility in the popup of option

  • 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

  • I want to trust my pc but my phone number is not in use... How to upgrade my number to receive a code

    Hello... I just had to have my 8 reinstalled windows as was the problem of software... I now have to go 'confidence to my pc', but mobile number which I am connected to the origin is more exists because I have a new number but do not know how to upgrade my number so I can get the code?   otherwise I have to wait a month before this is done?   'M not savvy PC so advice will graciously be recd

    Thx a lot

    Hi Sally,

    Why don't you directly chat with the Microsoft Account support team, they are an expertise on the treatment of issues related to the Microsoft account.

    Microsoft email support
    Microsoft support chat

  • How to find the number of data items in a file written with the ArryToFile function?

    I wrote a table of number in 2 groups of columns in a file using LabWindows/CVI ArrayToFile... Now, if I want to read the file with the FileToArray function so how do I know the number of items in the file. during the time of writing, I know how many elements array to write. But assume that I want the file to be read at a later time, then how to find the number of items in the file, so that I can read the exact number and present it. Thank you all

    Hello

    I start with the second question:

    bytes_read = ReadLine (file_handle, line_buffer, maximum_bytes);

    the second argument is the buffer to store the characters read, so it's an array of characters; It must be large enough to hold maximum_bytes the value NULL, if char [maximum_butes + 1]

    So, obviously the number of lines in your text tiles can be determined in a loop:

    Open the file

    lines = 0;

    While (ReadLine () > 0)

    {

    lines ++;

    }

    Close the file

  • How to give a limitation of internet access to users via gpedit.msc?

    How to give a limitation of internet access to users via gpedit.msc

    Hello

    Follow the below mentioned article:

    How to use the Group Policy Editor to manage the Local computer policy in Windows XP: http://support.microsoft.com/kb/307882

Maybe you are looking for

  • notification of messages has stopped working

    For some reason my Iphone 5 has ceased to send a notification or beeps when I receive a message txt;  All the settings seem to be correct.  Did I miss something?

  • Pavilion dm1: HP Pavilion dm1 4020ew updates

    What is the most powerful processor can I place on HP Pavilion dm1 4020ew? Is - it possible to Exchange (upgrade) in this netbook processor? If the CPU is soldered (immutable)? Why isn't this information in the statement? At the moment it has AMD E-4

  • UMI 772 Digital Out

    Hello I was intending on using the UMI-7772 to provide control for pneumatic valves signals and also control some return values.  There are 16 digital i/o lines available on the UMI-7772.  The manual States the 3-27: «These signals is configurable as

  • Internet a serious - unable to connect to any site problems, timeout problem

    Hello I am facing a problem when I am trying to connect to the internet, the problem is that I am getting timeout error.When I see the State it shows me Envoy: 193448 received: 123 The problem is that I can see the bytes sent fom my computer at the r

  • Vista SP1 installation failed and now my system is unable to start.

    I tried to install the Vista Service Pack 1 (SP1) and it stalled for hours with this line of text on the screen nflickering: !! 0xc01a001d! 28461/88529 (\Registry\Machine\COMPONENTS\DerivedData...) I have a Toshiba satellite laptop computer with Vist