Fired or similar fees within a State

Hello!

Let me explain my problem:

I have a few references based on a range of a display value, for example, let's say I have a column of the Department, the salary and emp_id column. And I display information like that at the moment:

Select the Department,

Count (case when salary < 1000 then 1 other null end) as salary_under_1000,

Count (case when salary > 1000 then end otherwise null) as salary_above_1000

(a table)

Group of Department;

But! I need to display more than two columns, the IDS of employees for each of the leaders above (note that LISTAGG does not work for me because of its limitation). So what I mean is that I need the result to be something like this:

Department

salary_under_1000

salary_above_1000 salary_under_1000_emp_ids salary_above_1000_emp_ids
12311, 128,7,6
23210,15,165.2
311194

I tried this:

Select the Department,

Count (case when salary < 1000 then 1 other null end) as salary_under_1000,

Count (case when salary > 1000 then end otherwise null) as salary_above_1000,

cases where the salary < 1000 then collect (emp_id) end as salary_under_1000_emp_ids,

cases where salary > 1000 can collect (emp_id) end up as salary_above_1000_emp_ids

(a table)

Group of Department;

But it gives me the error: not a GROUP BY expression.

I also tried the query like this:

collect (cases where the salary < 1000 then end emp_id)

But the wrong again: '

ORA-00932: inconsistent data types: expected UDT.

00932 00000 - ' incompatible data types: wait %s %s got. "

* Cause:

* Action:'

So now I ask you of no workaround, ideas, anything that might be useful.

Thanks in advance!

* Just want to note that I tried to put a case hooks LISTAGG condition and it does not give me an error but it produces bad results.

valeksandrova wrote:

@Solomon Yakobson Hi, I wrote in my first post that I tried this wayof the collection of writing and it gives me an error:

Well, I tried with XMLAGG and it looks very good, thanks!

The results are correct, but they have duplicates if someone has an idea how to remove them in the XMLAGG string that will be great!

Well, it is difficult to tell what the problem is when you post error without the query message, don't you think? In any case:

Select deptno,

Count (case when SAL< 1000="" then="" 1="" end)="" as="">

count (case where sal > 1000 then 1 end) as salary_above_1000,

Collect (box when SAL< 1000="" then="" empno="" end)="" as="">

collect (cases where sal > 1000 then end empno) salary_above_1000_emp_ids

WCP

Deptno group

/

SQL > select deptno,.
2 count (case when sal< 1000="" then="" 1="" else="" null="" end)="" as="">
3 count (case when sal > 1000 then 1 other null end) as salary_above_1000,
4 collect (box when sal< 1000="" then="" empno="" end)="" as="">
5 collect (cases where sal > 1000 then end empno) salary_above_1000_emp_ids
6 of PEM
7 Group of deptno
8.

DEPTNO SAL_UNDER_1000 SALARY_ABOVE_1000 SALARY_UNDER_1000_EM SALARY_ABOVE_1000_EM
---------- -------------- ----------------- -------------------- --------------------
10 0 3 SYSTP9S6TFQaISqi/Sd3/Sd3 SYSTP9S6TFQaISqi
XdLsDYA is (XdLsDYA ==(7782, 7934))
7839)

20 1 4 SYSTP9S6TFQaISqi/Sd3/Sd3 SYSTP9S6TFQaISqi
XdLsDYA == (7369) XdLsDYA == (7566, 7902
7876, 7788)

DEPTNO SAL_UNDER_1000 SALARY_ABOVE_1000 SALARY_UNDER_1000_EM SALARY_ABOVE_1000_EM
---------- -------------- ----------------- -------------------- --------------------
5 1 30 SYSTP9S6TFQaISqi/Sd3/Sd3 SYSTP9S6TFQaISqi
XdLsDYA == (7900) XdLsDYA == (7499, 7844
7698, 7654, 7521)

SQL >

Now on XMLAGG & duplicates. Only direct no:

with t as)

Select deptno,

Count (case when SAL< 1000="" then="" 1="" end)="">

County (cases where sal > 1000 then 1 end) salary_above_1000,.

(cast ((case when sal collect value< 1000="" then="" job="" end)="" as="" ku$_vcnt))="">

the value (cast (cost vires (cases where sal > 1000 jobs then end) as ku$ _vcnt)) salary_above_1000_jobs

WCP

Deptno group

)

Select deptno,

sal_under_1000,

salary_above_1000,

(select rtrim (xmlcast (xmlagg (xmlelement (e, column_value, ',')) as clob), ',') table (salary_under_1000_jobs)) salary_under_1000_jobs;

(select rtrim (xmlcast (xmlagg (xmlelement (e, column_value, ',')) as clob), ',') table (salary_above_1000_jobs)) salary_above_1000_jobs

t

/

DEPTNO SAL_UNDER_1000 SALARY_ABOVE_1000 SALARY_UNDER_1000_JO SALARY_ABOVE_1000_JOBS
---------- -------------- ----------------- -------------------- -----------------------
10 0 3 PRESIDENT DIRECTOR, REGISTRAR.
20 1 4 CLERK CLERK MANAGER, ANALYST.
30 1 5 CLERK SELLER, MANAGER

SQL >

SY.

Tags: Database

Similar Questions

  • Function within the statement call box SQL

    I have a procedure with many cases not to validate inside statements that compare the data in a table and fill in a description of the error of the dates. (snip of the size of the code below)

    create or replace procedure "PROC_TEMP_UPDATE"
    is
    begin
    update temp_update
    set error_desc = 
        CASE
        WHEN (error_desc != 'MATCH')
            THEN 'PCFN/TCN combo not found in destination table.'
        WHEN (error_desc = 'SKIP')
            THEN NULL
        WHEN (ge_ata is null and az_ata is not null)
            THEN 'Enter GE ATA Date before entering AZ ATA Date.'
        WHEN ((ge_ata is not null and az_ata is not null) and ge_ata > az_ata)
            THEN 'GE ATA Date cannot be greater than AZ ATA Date.'
           end proc_temp_update;
    
    
    

    Instead of having to enter the bottom 2 when reporting for each date, I created these functions:
    (Function 1: check if Date1 is null and Date2 is not.)
    Function 2 these two dates are not null, check if Date1 is greater than Date2.)

    function Is_D1_NULL
                (Date1  DATE, Date2 DATE)
                return BOOLEAN is
    
          result     BOOLEAN := FALSE; 
       begin 
          if (Date1 is null and Date2 is not null) then  
             result := TRUE; 
          end if; 
          return (result); 
       end Is_D1_NULL;
    

    You cannot use Boolean in SQL queries.  You must modify your function to return something like Y/N or 1/0 and assess against that.

    That said, move the engine of SQL and PL/SQL is, relatively speaking, cheap, so I let just the comparisons as they are in instruction box instead of calling a function.

    John

  • Set the values of constraint within the States

    Hi all, in the attached code I have a condition called "pods1" - I have a canvas called pod1 when I am in design mode and I change my status to "pods1", it works fine - but if I change this State programmatically, it said 'left' can be found in < mx:canvas > object? in design mode, he can see the parameter and the code, that it seems strange

    Any help much appreciated.

    I found a workaround - in the example above if you use the following: -.




    SetStyle seems to work as we would expect there would be SetProperty!

    Concerning
    SWT

  • How to get the item currently being processed within the State

    Will there be any environment variable that contains the element, as there are some pages and app?

    I would use it in terms of the element. The condition would be coded in a package and called several times through the elements. The problem now is that I need to pass the name of the element in the parameter of the function.

    Any idea?

    It is not available. We hope to provide this in a future release to allow plans for leave to use a code generic, similar to your goals.

    Scott

  • Slide show within a single State that belongs to a multistate?

    Hello!

    I want a slide show that goes with it, say different albums, and then I want every albums to show imageslideshows, is it possible? I can't work a slideshow within a State.

    Thank you

    Ruben.

    You must anchor the MSO slideshow in a block of text and add this text

    framework of the State in the other MSO.

    Bob

  • Referring to entities of a grandchild in an equation (statement of conclusion)

    Hi all

    Our project work with imported data of a Siebel OPA via Webshere database. We created the entities and attributes in OPM (10.2) in a similar structure to the way in which the data sources are organized in Siebel. Our data are modeled in 3 levels of nested entities (4 If you include the 'Global' entity). Here is the example that I work with:

    Top: Global
    2nd: the case
    3rd: the order of the Tribunal
    4th: the obligation

    I want to calculate the total value on a given case of obligations when the frequency of the obligation is "Weekly" (for example). I have successfully used ForScope, ExistsScope, etc., by the help topic "because of the relationship between two entities' in other rules bring entities into the same containment relationship within reach, where I am able to nest rules at several levels by examples, with each rule nested bringing another entity nested within the scope. However the problem here is that I try to integrate a grandchildren entity carried within the statement of a conclusion, where it seems that I can only refer to a parent-child relationship (i.e. within the InstanceSumIf function).

    I wonder if there is a simple way to achieve what I'm trying, or if we must rethink how we modeled our entity relationships, for example to move "duty" at the same level as 'order '.

    Any help will be greatly appreciated!
    Philippe

    I'm guessing that you have described entities are show containment relationships and that everything is connected by a one-to-many relationship? In other words:
    * Each OPA assessment can have several instances of
    * Each case can have several court orders
    * Each order of the Court may have multiple bonds

    Is this correct? Just curious... Is there a reason why each OPA assessment must be able to do the logic on multiple cases in the determination of one? For example do you ever need to work on things like the total cost of all cases? There may well be a good reason for the 'cases' are nested Global slot, but I don't know what your source material, so I'm just a question.

    Anyway... it is not unusual to have some data nested a few levels down and have to do a calculation of amount up to the top of the hierarchy of entities. When you need to do this, you can do the math in several steps. In your example, you could work the weekly obligations by order of the Court, then use this conclusion to work weekly obligations for each case, e.g.

    the cost of weekly obligations of the court order = InstanceSumIf (bonds, the obligation of cost, frequency of duty per week)

    the cost of weekly obligations for the case of = InstanceSum (court order, the cost of the weekly obligations of the order of the Court)

    See you soon,.
    Jasmine

  • Race conditions manifested in the state machine in queue

    Hello

    I ' am developing a vi in which I use a design of producer-consumer model.
    the producer s enqueue States for the consumer. but at a certain point in execution of I want to enqueue the next state of the statemachine consumer, within the State of the consumer himself. This causes a problem?
    in other words I have given queue in the loop of consumer can also. so the man the next state of consumers will depend on the data in queue

    Thank you

    I make extensive use of Handleres of Message queue where the "producer" and the consumer enqueue for the same queue.

    A "Firinstance" of work today: here are two screenshots of a part of the same code

    The top loop controls the State of a semi autonomous process where data is collected.

    1. an event is detected, triggering the start of the measuring cycle
    2. Data are being gathered
    3. Another event tells the top loop that it's time to stop collecting data and "Analize" is sent to the end opposite to the consumer
    4. The buffer empty analize, formats the data and continues to the State of "Log".

    The thing to remember is to use a priority queue.  Enqueue to place free and flush properly, in front of end control.  See also 'A trip to Grandma's House'.

    It is a very powerful technique for applications where you want abstract on the 'what' and 'When' the how and just leave a "do".

    And Yes, if I had chosen a unrestricted data (string, var) rather than an enum type and built the lower loop as a child class, you have a "player".

  • Adding values to a table in a State Machine

    I'm building a VI that control several instruments and then takes data from these measures and applies them to the calculations appropriate to the materials science, such as the resistivity and Seebeck effect. I created a state machine that establishes a level of tension and takes three sets of three different measuring points, using a scanner Keithley 7001 and nanovoltmeter Keithley 2182. I'm now trying to find a way to take action and put them in three separate tables so that I can use them for analysis later. I prefer the tables because there are several screws that can help me to do what I have to do easily (for example, the VI means), but if something works better, I am open for entry.

    My simple question: what is the best way to take measurements of the case 1 SOUL, SOUL 2 and 3 soul and store them in three separate tables?

    I enclose my VI.

    Edit: Just after the announcement, I decided that I will take the structures of sequence holding the sections measure and instead turn them into business within the state machine. I'll post a new VI of the present when I finished.

    In this example, I used a structure called soul #. This structure allows each soul to have its own unique array.

    The structure is an array of clusters. The cluster contains a string array named Data.

    I hope this helps.

  • Shift registers and state machines

    I am creating a VI that controls a power supply, a switching system and a nanovoltmeter so that I can measure the Seebeck of different materials. After reading through these forums, it seems that the overwhelming opinion was that the state machine is much better than the structures of the cell, which was what I was going to initially use. However, I have a problem. To control my sourcemeter, I the user to enter the number of steps (time machine increases the voltage), a final voltage and output voltage. Of these, I get the value of the increment. However, within my state machine that the first step is transferred to the structure of the case. I used probes to see how information is moving, and it seems that the voltage value is increment correctly but the real VI for the power supply receives the initial value. I'm just wondering how to pass the updated values in the structure dealing with each iteration.

    I've included the vi. It is far from over because I'm sure you will see, but my current problem in the case of 'change v '. That said, if anything jumps out and you feel the immediate needs, feel free to say it, I learn and I accept all the entries.

    I recommend that you run your VI highlight execution lit.  This will help you understand what's happening better.

    Just to remind, only 1 case in structure can work iteratively.  If you have a TRUE/FALSE in the middle of a VI case structure you plan to run both cases?  Of course not.  Same thing here.

    So keep your current tension in a shift register and increment only when you are in the case of set.  Stop your state machine when your voltage exceeded the stop voltage (have a just State to check this box to make things easier).

  • Elapsed time delay does that once in the state machine

    Hello.  I have problems using the delay to show the seconds remaining on an expectation not in a simple state machine.  I have a front panel countdown indicating the time remaining for the step.  I thought that the delay of elapsed time was the way to do.  The problem is the vi work correctly the first time.  But then after that the calendar does not seem to reset at the time I had put.  If I remove the delay and just stick a waiting time in the State, the vi is exhausted because I expect.  This is just to give the user an idea of the time remaining.  What I missing when using the passage of time, or it's just the wrong tool for the job?

    A small question, is that I would like to move the tasks, in this case the LED outside of the loop, so I don't have to repeat the code.  But when I tried moving them outside with only allow constants within the State, they do not work as I expected.  If you have tasks such as operating a set of Boolean values that you are used in several States, what is the the cleaner way to do it without repeating the code?

    Thanks for the help.

    See how it works for you.

  • Add to or the modification of existing States

    I'm creating a form to reach us and widget used simple contact form of the Muse.

    My question: How can I change the action of the State OR can I add other interactivity in Muse in other States?

    For example, I vacuum, Non-empty, Rollover, Focus and error.    Can I add Active when a user clicks on it?   It seems to be wired by Muse, because the forms come with radio buttons and I don't want the radio buttons.   Basically, I wanted to bold type in a different color when clicked.

    You can make changes within the States itself, the content you want displayed with the click of the mouse means action will have to be changed in this State only.

    Thank you

    Sanjit

  • using the case statement


    Hello

    How can I convert a code for the below sql case statement:

    If)

    (length of (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < = 0 OR tmp_co_orig_val == 1 OR tmp_co_orig_val > = 9999999)

    OR

    ((tmp_co_orig_val == 999999 AND (length of (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15)))

    Start

    tmp_collatvalue = «»

    tmp_msg_cd = 115

    end

    Is the case statement below that I wrote is correct. I don't have an environment now to test.  Please advice.

    BOX WHEN (CHAR_LENGTH (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < 0 OR tmp_co_orig_val = 1 OR tmp_co_orig_val = > = 9999999)

    OR (tmp_co_orig_val = 999999 AND (CHAR_LENGTH (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15))

    THEN tmp_collatvalue IS NULL AND tmp_msg_cd = 115

    END

    Hello

    937454 wrote:

    Thanks Frank. Really helps. But I have to write a sql statement

    But can you also specify, if I made a mistake in my code, or it's ok.

    There are no CASES reported in Oracle SQL.

    Oracle SQL has BOX expressions, but they only return a single value.  You cannot set 2 columns in the same expression BOX.

    Perhaps the best thing to do in pure SQL for you is to write a CASE expression, very similar to the CASE statement above, in a subquery and use the results of this in 2 separate expressions of BOX (very simple) in a Super application.

  • Need help with CASE When statement in a Where Clause

    So I have a SQL (simplified for this forum)

    Select t1.*
    from table1, table2 t2 t1
    where t1.field1 = t2.field1
    and when t1.field2 is null then trunc (sysdate) < = trunc (t1.date1 + 17)
    of another trunc (sydate) > = end of trunc (t2.date2 + t2.date3)

    I end up getting an error ORA-00905: lack of keyword

    I'm sure that I just got something here involved.

    You can not make the comparison within the statement underlying case like this. Assuming you have appropriate data types, something like this should work

    Select t1.*
    from table1 t1, table2 t2
    where t1.field1 = t2.field1
      and ((t1.field2 is null and
            trunc(sysdate) <= trunc(t1.date1 + 17)) or
           trunc(sydate) > = trunc(t2.date2 + t2.date3))
    

    John

  • My sql is massively leaves to be desired... (Remove the statement)

    Hello world.

    After skimming the forum, I started to think that me to come here with my sql noobie problem, might be overkill... but here goes.

    It's simple. I need to delete all the records in the table 2, which is not used as a FK in table 1. I * in 'fat' * records I want to remove.

    My current sql:

    remove from Table2
    If Table2.StatId not in
    (select from Table1 StatId)


    The two tables have approximately 1.2 million records each, which makes my SQL course takes forever (stopped after 1:30).


    Table1:
    ID (PK) StatId (FK) ReqId (FK)
    1 10 100
    2-11-110
    3-11-120
    4 14 130
    5-15-135
    6 17 150
    7 18 155
    8 18 160
    9 19 165



    Table2
    StatId (PK) name
    10 John
    11 Malcor
    * 12 Jeff *.
    * Sara 13 *.
    Melissa 14
    Camilla 15
    * Jessie 16 *.
    17 Martin
    18 Peter
    Frank 19
    * Bret 20 *.

    Is there a better way to do this?

    I am quite new to sql, and the large amount of data makes my flawed sql stand out even more.

    Thanks in advance.

    Hello

    a DML statement like delete or update consists of two parts: the part 'selection', which identifies the lines to operate on and the part 'Edit' that performs the desired action. The first step in setting up a hanging LMD stated must determine which of the two phases is responsible. You can do that by looking at explain plan or check wait events incurred during the session. Or, you can run a SELECT similar to your update statement and see how long it takes (if you are not familiar with SQL execution plans, it'll be easier):

    select *
     from Table2
    where Table2.StatId not in
    (select StatId from Table1)
    

    If the problem is with the part 'selection', then you must tune or add some index - display the plan and the DDL to your tables and indexes, and we will help you with that. If the problem is with the section "Edit", then solution depends on the exact nature of the problem (the simplest scenario is that another session is keeps a lock - then you must simply kill another session or complete the transaction).

    Best regards
    Nikolai

  • using an Exit statement for a deletion without affecting an oracle error msg

    Hello all;

    I have one similar to this delete statement below
      delete from tbl_one t
      where t.tbl_one_location = location 
      and location not in (select distinct p.issuearea  from tbl_two p);
    the delete statement is in a package, however I would like to make out a simple message to indicate if the deletion was successful which means that a real element has been deleted and if this was not successful another statement for this.

    I have an idea in my mind which is to track the number of items in tbl_one before deleting and then check the count after removal and if the number is lower, the deletion was successful... therefore the output message. Is the best way to go or there at - it an easier way to do it.

    Thank you, any help is appreciated.

    You could put something like this directly after the DELETE statement:

    IF SQL%ROWCOUNT > 0 THEN
            DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT || ' items deleted.');
    ELSE
            DBMS_OUTPUT.PUT_LINE('Nothing deleted!');
    END IF;
    

    SQL % ROWCOUNT attribute: how many lines were affected?

Maybe you are looking for

  • El Capitan crash, Chrome is the problem?

    Hello recently I came across a problem when you browse websites with Chrome. (I guess) All of a sudden my Macbook pro crashed and he did several times in a row at the start of Chrome and navigation on Web sites. This has never been a problem before.

  • Microsoft digital Image pro 10

    When I copy part of an image and paste it into the same image, so I can remodel or narrowing it or what that is i have a problem. When I paste that the quality of the image seems as if he has been to the negative format, the quality is horrible. It d

  • I repeatedly get update error...

    I am running Windows 7 on a HP Pavilion laptop... I can't update my software driver (HP advisor resets without having to install), my mozilla firefox (seems to think there are other versions of the open program) and I can not install the next update

  • I have problem-. TAR file

    I downloaded the .tar file, but I don't know how to use it. Can someone help me?

  • Windows Vista - Task manager problems

    I use Windows Vista Home Premium and when I try to use the task manager the following message "taskmgr.exe - bad image, C:\Windows\system32\VDMDBG.dll is not designed to run on Windows or it contains an error. Although bought new computer came with V