Doubts formidable wrt "select", "join" and "group by" clause to calm a while...

Dear all,

Kindly advise on below 2 doubts which have been daunting for quiet some time. The bottom has forced our requests to take alternative routes to receive solutions.

Doubt 1) is it possible for us to use 'select (*)' with a group and a join clause, if we have at least 2/3 tables with minimum 15-20 columns... given the constraint of having to add all the names column in the group by clause.

Question 2) is it possible to use "select" (*) with the exception of a single column of the table?
That is to say, I hate the output of a statement select (*) to have the entire field except a field in a table

Ask your advisor for the same thing. Excuse me because I have no examples to illustrate this point in time. A successful idea will do.

Thank you and best regards,

Séverine Suresh

Hey, Sebastian,

Séverine Suresh - 3035408 wrote:

Dear all,

Kindly advise on below 2 doubts which have been daunting for quiet some time. The bottom has forced our requests to take alternative routes to receive solutions.

Doubt 1) is it possible for us to use 'select (*)' with a group and a join clause, if we have at least 2/3 tables with minimum 15-20 columns... given the constraint of having to add all the names column in the group by clause.

Sure.  If you had problems, you did it wrong.  Your postal code, examples of data (CREATE TABLE and INSERT statements) and the results desired from these data.

Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

Normally, you don't want to ' SELECT *...» "in a join.  Are most joins are equijoins, ' SELECT *...» "produced 2 copies of / columns used for Assembly.  In addition, many tables have columns (for example, modified_date) that are not necessary in most applications.

All columns must be included explicitly in a GROUP BY clause. You cannot use * it.

You can not have parentheses around the * in ' SELECT *...» ».  You might think 'SELECT COUNT (*) '

Question 2) is it possible to use "select" (*) with the exception of a single column of the table?
That is to say, I hate the output of a statement select (*) to have the entire field except a field in a table

...

No.; If you don't want a particular column in the result set, you cannot use "SELECT *...» ».

Your front end can have so as not to display a column in the result set.  For example, in SQL * more:

COLUMN modified_date NOPRINT

means that you won't see any column called modified_date.

Tags: Database

Similar Questions

  • Rewrite the query with joins, and group by

    Hello

    It's an interview question.

    Table names: bookshelf_checkout
    virtual library

    And the join condition between these two tables is title

    We need to rewrite under request without using the join condition and group by clause?

    SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out"
               FROM bookshelf_checkout bc,bookshelf b
               WHERE bc.title(+)=b.title
               GROUP BY b.title;
    When I was in College, I read most of SELECT statements can be replaced by operations base SQL (DEFINE the OPERATORS). Now, I am rewriting the query with SET operators, but not able to get the exact result.

    Kindly help me on this.

    Thank you
    Suri

    Something like that?

      1  WITH books AS (
      2  SELECT 'title 1' title FROM dual UNION ALL
      3  SELECT 'title 2' FROM dual UNION ALL
      4  SELECT 'title 3' FROM dual ),
      5  bookshelf AS (
      6  SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL
      7  SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL
      8  SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual )
      9  SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs
     10  UNION
     11  (SELECT b.title, NULL FROM books b
     12  MINUS
     13* SELECT bs.title, NULL FROM bookshelf bs)
    SQL> /
    
    TITLE   MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE)
    ------- ------------------------------------------------------------
    title 1                                                           14
    title 2                                                           44
    title 3
    

    Lukasz

  • Difference-conditions (join and a Where Clause)

    Hi people,

    I need to clearly agree on what a difference exactly when we put any condition in INNER JOIN and the WHERE Clause.

    I have tried both way and found the same results. Even in the statistics Plan not much differences.  Any help would be appreciated.

    As:

    1 here, I use filter store in the join condition - Inner

    "SELECT i., Gl * Sc1.Item I.

    Inner Join Sc1.Part P

    On P.Part_Id = I.Part_Id

    Inner Join Sc1.Location Gl

    On Gl.Location_Id = I.Location_Id

    And Gl.Location_Id in (1767, 1747,202,1625)

    Inner Join Sc1.Condition C

    On C.Condtion_Id = Gl.Condition_Id

    Where I.Inactive_Ind = 0

    And I.Condition_Id! = 325

    2. here I use filter store in Where clause-

    SELECT i., Gl * Sc1.Item I

    Inner Join Sc1.Part P

    On P.Part_Id = I.Part_Id

    Inner Join Sc1.Location Gl

    On Gl.Location_Id = I.Location_Id

    Inner Join Sc1.Condition C

    On C.Condtion_Id = Gl.Condition_Id

    Where I.Inactive_Ind = 0

    and I.LOCATION_ID in (1767, 1747,202,1625)

    And I.Condition_Id! = 325

    Thank you

    Mark



    Hello

    MarkCooper wrote:

    Hi guys,.

    To reply to all - I understand.

    1. its good practice to use conditions / filter (except CLAUSE) in the WHERE Clause rather Inner join? bon ?

    2. now, in my previous example. We could use the location code in where clause as it was in the two tables.

    What is the best practice to use the code to location here ( 1 /2) ?

    1. here I use filter store in the Inner join condition ( guess the location code is not in the article table)).

    "SELECT i., Gl * Sc1.Item I.

    Inner Join Sc1.Part P

    On P.Part_Id = I.Part_Id

    Inner Join Sc1.Location Gl

    On Gl.Location_Id = I.Location_Id

      And Gl.Location_Id in (1767, 1747,202,1625)

    Inner Join Sc1.Condition C

    On C.Condtion_Id = Gl.Condition_Id

    Where I.Inactive_Ind = 0

    And I.Condition_Id! = 325

    2. here I use filter store in Where clause (assume that the location code is not in the article table)-

    SELECT i., Gl * Sc1.Item I

    Inner Join Sc1.Part P

    On P.Part_Id = I.Part_Id

    Inner Join Sc1.Location Gl

    On Gl.Location_Id = I.Location_Id

    Inner Join Sc1.Condition C

    On C.Condtion_Id = Gl.Condition_Id

    Where I.Inactive_Ind = 0

      And Gl.Location_Id in (1767, 1747,202,1625)

    And I.Condition_Id! = 325

    Thank you

    If location_id isn't in the item table, then the join condition

    On Gl.Location_Id = I.Location_Id

    will cause an error.

    Once more, it should not affect results or performance if a condition like

    Gl.Location_Id in (1767, 1747,202,1625)

    is in the clause or the WHERE clause.  No matter if it is be a column called location_id in any other table, or if the same column Gl.Location_Id is used in other conditions.

    As this condition only refers to a table (GI), I recommend you put it in a WHERE clause, just to make the code clearer.

    Yet once, this applies only to the inner joins, not for outer joins and not to CONNECT BY queries.

  • Update with the join and group by

    Hi all

    I'm currently updating multiple columns in a table from an inner join query.
    First one recover the affected rows and values that I need for the update (which I call this subquery ED_Query).
    It is important to note that this subquery has a group of and and the having clause.

    My first attempt (using the query running in the SQL Server query) fails:

    SQL > update ED_Update
    2 set ED_Update.dtHoraInicioReal = ED_Query.dtHoraInicioReal,
    3 ED_Update.dtHoraFinReal = ED_Query.dtHoraFinReal,
    4 ED_Update.fPorcentajeRealizado = ED_Query.fPorcentajeRealizado
    HISTORICOS_AVANZA 5. HSAE_HIS_EXPEDICIONDIARIA ED_Update
    inner join 6)
    7. select distinct ED.iIdExpedicion, ED.iIdExpedicionDiaria,
    8 MAX (PT.iOrdenEnTrayecto) + 1 as iNumParadas,
    9 MAX (HPP.iOrden) as iOrdenUltimaParada,
    10 MIN (dtHora_LlegadaReal + iTiempoEnParada /(24*60*60)) as dtHoraInicioReal,
    11 MAX (dtHora_LlegadaReal) as dtHoraFinReal,
    12 100 * cast ((MAX (HPP.iOrden) + 1) as float) / cast ((MAX (PT.iOrdenEnTrayecto) + 1) as float) as fPorcentajeRealizado
    13 of HISTORICOS_AVANZA. ED HSAE_HIS_EXPEDICIONDIARIA
    14 left join HISTORICOS_AVANZA. HSAE_HIS_HORAPASOPARADA HPP
    15 ED.iIdExpedicion = HPP.iIdExpedicion and ED.dtJornada = HPP.dtJornada
    16 left join AVANZA. SAE_URB_PARADASTRAYECTO PT on ED.iIdLinea = PT.iIdLinea and ED.iIdTrayecto = PT.iIdTrayecto
    17 where ED.dtJornada = TO_DATE (January 14, 2013 ',' DD/MM/YYYY ') and ED.iIdExpedicion in (-131076)
    18 ED.iIdExpedicion, ED.iIdExpedicionDiaria, ED.dtHoraInicioReal, ED.dtHoraFinReal group
    19 having ED.dtHoraInicioReal <>min (dtHora_LlegadaReal + iTiempoEnParada /(24*60*60))
    20 or ED.dtHoraFinReal <>max (dtHora_LlegadaReal)
    (21) ED_Query
    22 we ED_Update.iIdExpedicionDiaria = ED_Query.iIdExpedicionDiaria;

    ERROR on line 5:
    ORA-00933: SQL not correctly completed command.

    Subquery (ED_Query) work fine in Oracle, so I suspect that the problems are when I mix with the update clause.

    SQL > select distinct ED.iIdExpedicion, ED.iIdExpedicionDiaria,.
    2 MAX (PT.iOrdenEnTrayecto) + 1 as iNumParadas,
    3 MAX (HPP.iOrden) as iOrdenUltimaParada,
    4 MIN (dtHora_LlegadaReal + iTiempoEnParada /(24*60*60)) as dtHoraInicioReal,
    5 MAX (dtHora_LlegadaReal) as dtHoraFinReal,
    6 100 * cast ((MAX (HPP.iOrden) + 1) as float) / cast ((MAX (PT.iOrdenEnTrayecto) + 1) as float) as fPorcentajeRealizado,
    7 ED.dtHoraInicioReal ED_dtHoraInicioReal, ED.dtHoraFinReal as ED_dtHoraFinReal, ED.fPorcentajeRealizado as ED_fPorcentajeRealizado
    8 of HISTORICOS_AVANZA. ED HSAE_HIS_EXPEDICIONDIARIA
    9 left join HISTORICOS_AVANZA. HSAE_HIS_HORAPASOPARADA HPP
    10 on ED.iIdExpedicion = HPP.iIdExpedicion and ED.dtJornada = HPP.dtJornada
    11 left join AVANZA. SAE_URB_PARADASTRAYECTO PT on ED.iIdLinea = PT.iIdLinea and ED.iIdTrayecto = PT.iIdTrayecto
    where the ED.dtJornada 12 = TO_DATE (January 14, 2013 ',' DD/MM/YYYY ') and ED.iIdExpedicion in (-131076)
    13 group of ED.iIdExpedicion, ED.iIdExpedicionDiaria, ED.dtHoraInicioReal, ED.dtHoraFinReal, ED.fPorcentajeRealizado
    14 after ED.dtHoraInicioReal <>min (dtHora_LlegadaReal + iTiempoEnParada /(24*60*60))
    15 or ED.dtHoraFinReal <>max (dtHora_LlegadaReal);

    IIDEXPEDICION IIDEXPEDICIONDIARIA INUMPARADAS IORDENULTIMAPARADA DTHORAINI
    ------------- ------------------- ----------- ------------------ ---------
    DTHORAFIN FPORCENTAJEREALIZADO ED_DTHORA ED_DTHORA ED_FPORCENTAJEREALIZADO
    --------- -------------------- --------- --------- -----------------------
    -131076 5662 406 15 JANUARY 13
    15 JANUARY 13 JANUARY 15, 13 15 JANUARY 13 0

    -131076 5663 406 15 JANUARY 13
    15 JANUARY 13 JANUARY 15, 13 15 JANUARY 13 0

    -131076 5664 406 15 JANUARY 13
    15 JANUARY 13 JANUARY 15, 13 15 JANUARY 13 0

    After reading this forum, I have change the query and try the following:

    SQL > UPDATE
    () 2
    3. select distinct ED.iIdExpedicion, ED.iIdExpedicionDiaria,
    4 MAX (PT.iOrdenEnTrayecto) + 1 as iNumParadas,
    5 MAX (HPP.iOrden) as iOrdenUltimaParada,
    6 MIN (dtHora_LlegadaReal + iTiempoEnParada /(24*60*60)) as dtHoraInicioReal,
    7 MAX (dtHora_LlegadaReal) as dtHoraFinReal,
    8 100 * cast ((MAX (HPP.iOrden) + 1) as float) / cast ((MAX (PT.iOrdenEnTrayecto) + 1) as float) as fPorcentajeRealizado,
    9 ED.dtHoraInicioReal ED_dtHoraInicioReal, ED.dtHoraFinReal as ED_dtHoraFinReal, ED.fPorcentajeRealizado as ED_fPorcentajeRealizado
    HISTORICOS_AVANZA 10. ED HSAE_HIS_EXPEDICIONDIARIA
    11 left join HISTORICOS_AVANZA. HSAE_HIS_HORAPASOPARADA HPP
    12 on ED.iIdExpedicion = HPP.iIdExpedicion and ED.dtJornada = HPP.dtJornada
    13 left join AVANZA. SAE_URB_PARADASTRAYECTO PT on ED.iIdLinea = PT.iIdLinea and ED.iIdTrayecto = PT.iIdTrayecto
    14 where ED.dtJornada = TO_DATE (January 14, 2013 ',' DD/MM/YYYY ') and ED.iIdExpedicion in (-131076)
    Group 15 of ED.iIdExpedicion, ED.iIdExpedicionDiaria, ED.dtHoraInicioReal, ED.dtHoraFinReal, ED.fPorcentajeRealizado
    16 having ED.dtHoraInicioReal <>min (dtHora_LlegadaReal + iTiempoEnParada /(24*60*60))
    17 or ED.dtHoraFinReal <>max (dtHora_LlegadaReal)
    18)
    19 SET ED_dtHoraInicioReal = dtHoraInicioReal,
    20 ED_dtHoraFinReal = dtHoraFinReal,
    21 ED_fPorcentajeRealizado = fPorcentajeRealizado;

    ERROR on line 2:
    ORA-01732: operation non-legal data manipulation on this point of view

    Little help?

    Thanl in advance.

    Published by: 984483 on 28-ene-2013 01:48

    Hello

    Thanks for posting the CREATE TABLE and INSERT.
    Don't forget to post the desired results of these sample data, i.e. the content of the or the tables changed after the UPDATE is made.

    Is that what you want ed_update to look like after that everyhting is finished?

    DATE01      NUMBERMAX  NUMBERSUM
    ---------- ---------- ----------
    01/01/2013         30         60
    02/01/2013          0          0
    03/01/2013          0          0
    

    If so, here's a way to do it:

    UPDATE     ed_update     u
    SET     (numbermax, numbersum) =
         (
                 SELECT  MAX (number01)
              ,     SUM (number01)
              FROM     ed_query
              WHERE     date01     = u.date01
         )
    WHERE     date01     = TO_DATE ('01/01/2013', 'DD/MM/YYYY')   -- If wanted
    ;
    

    In Oracle, INNER JOIN works only in the FROM clause of a SELECT statement.
    When you want to update a table with values from another table, you can do a subquery correlated (as I showed above) or use the MERGER instead of UPDATE.

  • By the way where and group by clause Cursor

    I'm working on a procedure that generates a where clause clause and needs of a group by clause to return the correct results. I'm moving the two where and group variables in the cursor.

    The variables are is filled correctly, but when the cursor is created, variables are not in the cursor.

    Here's the code I'm working with. It is part of a package, but does no appeal to other parts of the package.

    PROCEDURE createFollowUpTask_Exposure (psUppgkedjetyp IN tis.tial.uppgkedjetyp%TYPE NULL by default,
    psAlarmtyp IN tis.tial.alarmtyp%TYPE by default NULL,
    psSubtyp IN tis.tial.subtyp%TYPE by default NULL,
    pnDays in NUMBER NULL by default,
    psKampkod IN tis.tiin.kampkod%TYPE by default NULL,
    psKatnr IN tis.tiin.katnr%TYPE by default NULL,
    psUtgava IN tis.tiin.utgava%TYPE by default NULL,
    psKatslag IN tis.tikg.katslag%TYPE by default NULL,
    psProdsyst IN tis.tikg.prodsyst%TYPE by default NULL,
    psUppgtyp IN tis.tiin.uppgtyp%TYPE by default NULL,
    psProdkod IN tis.tiin.prodkod%TYPE by default NULL,
    psStatus IN tis.tiin.status%TYPE by default NULL
    ) AS
    --
    cTIAL tis.tial%ROWTYPE;
    vLopnr tis.tial.lopnr%TYPE;
    vSqlWhere VARCHAR2 (4000);
    vGroupBy VARCHAR2 (1000): = "tiin.kampkod, tiin.abnr, tiko.fordsalj;
    cSelectCursor SYS_REFCURSOR;
    vSqlSelect VARCHAR2 (4000);
    psDays VARCHAR2 (50);
    cRec T_TIAL_REC;
    nCount number: = 0;

    --
    CURSOR cSqlSelect (SqlWhere IN VARCHAR2, GroupBy IN VARCHAR2) IS
    SELECT tiin.kampkod, tiin.abnr, tiko.fordsalj, MAX (tici.regdat) ALARMDATE
    OF tis.tiin
    JOIN tis.tiko ON tiin.kampkod = tiko.kampkod AND tiin.abnr = tiko.abnr
    JOIN core.tici ON tiin.kampkod = tici.kampkod AND tiin.abnr = tici.abnr AND tici.inplnr = tiin.inplnr
    WHERE 1 = 1 | SqlWhere
    GroupBy GROUP;
    --
    BEGIN
    -If these parameters are null, trigger the error
    IF psUppgkedjetyp IS NULL and psSubtyp IS NULL THEN
    raise_application_error (-20001,
    "String from the event or events must be assigned");
    END IF;
    -Fill the TIAL values
    IF psUppgkedjetyp IS NOT NULL THEN
    cTIAL.Uppgkedjetyp: = psUppgkedjetyp;
    END IF;
    --
    IF psAlarmtyp IS NOT NULL THEN
    cTIAL.Alarmtyp: = psAlarmtyp;
    END IF;
    --
    cTIAL.Handklass: = 't';
    cTIAL.Blobid: = 0;
    --
    IF pnDays IS NOT NULL THEN
    psDays: = '+' | pnDays;
    END IF;
    IF psSubtyp IS NOT NULL THEN
    cTIAL.Subtyp: = psSubtyp;
    END IF;
    -Create Where clause for cursor
    vSqlWhere: = ";
    IF psKampkod IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.kampkod ="' | psKampkod | " ' ;
    END IF;
    --
    IF psKatnr IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.katnr ="' | psKatnr | " ' ;
    END IF;
    --
    IF psUtgava IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.utgava ="' | psUtgava | " ' ;
    END IF;
    --
    IF psKatslag IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tikg.katslag ="' | psKatslag | " ' ;
    END IF;
    --
    IF psProdsyst IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tikg.prodsyst ="' | psProdsyst | " ' ;
    END IF;
    --
    IF psUppgtyp IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.uppgtyp ="' | psUppgtyp | " ' ;
    END IF;
    --
    IF psProdkod IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.prodkod ="' | psProdkod | " ' ;
    END IF;
    --
    IF psStatus IS NOT NULL THEN
    vSqlWhere: = vSqlWhere | "AND tiin.status ="' | psStatus | " ' ;
    END IF;
    -Browse all records in input parameters of the meeting and set values required TIAL.
    I'm IN cSqlSelect (vSqlWhere, vGroupBy)
    --
    LOOP
    -EXTRACT cSelectCursor INTO cRec;
    cTIAL.Kampkod: = ";
    cTIAL.Abnr: = ";
    cTIAL.Sign: = ";
    cTIAL.Alarmdate: = ";
    cTIAL.Kampkod: = i.Kampkod;
    cTIAL.Abnr: = i.Abnr;
    cTIAL.Sign: = i.fordsalj;
    cTIAL.Alarmdate: = i.alarmdate;
    --
    nCount: = nCount + 1;
    --
    IF vLopnr = - 1 THEN
    raise_application_error (-20002,
    "Error creating task for: ' | '. cTIAL.Kampkod |' '|| cTIAL.Abnr |' Sales representative: ' | cTIAL.Alarmdate);
    END IF;
    END LOOP;
    DBMS_OUTPUT. Put_line (' I created ' | nCount |) "documents.");



    END createFollowUpTask_Exposure;

    Thanks in advance for any help.

    Hello

    Welcome to the forum!

    Try this (untested) example:

    PROCEDURE createFollowUpTask_Exposure(psUppgkedjetyp IN tis.tial.uppgkedjetyp%TYPE DEFAULT NULL,
                                          psAlarmtyp     IN tis.tial.alarmtyp%TYPE DEFAULT NULL,
                                          psSubtyp       IN tis.tial.subtyp%TYPE DEFAULT NULL,
                                          pnDays         IN NUMBER DEFAULT NULL,
                                          psKampkod      IN tis.tiin.kampkod%TYPE DEFAULT NULL,
                                          psKatnr        IN tis.tiin.katnr%TYPE DEFAULT NULL,
                                          psUtgava       IN tis.tiin.utgava%TYPE DEFAULT NULL,
                                          psKatslag      IN tis.tikg.katslag%TYPE DEFAULT NULL,
                                          psProdsyst     IN tis.tikg.prodsyst%TYPE DEFAULT NULL,
                                          psUppgtyp      IN tis.tiin.uppgtyp%TYPE DEFAULT NULL,
                                          psProdkod      IN tis.tiin.prodkod%TYPE DEFAULT NULL,
                                          psStatus       IN tis.tiin.status%TYPE DEFAULT NULL) AS
       --
       cTIAL         tis.tial%ROWTYPE;
       vLopnr        tis.tial.lopnr%TYPE;
       vSqlWhere     VARCHAR2(4000);
       vGroupBy      VARCHAR2(1000) := ' tiin.kampkod, tiin.abnr, tiko.fordsalj';
       cSelectCursor SYS_REFCURSOR;
       vSqlSelect    VARCHAR2(4000);
       psDays        VARCHAR2(50);
       cRec          T_TIAL_REC;
       nCount        NUMBER := 0;
    
       FUNCTION fnc_cSqlSelect(SqlWhere IN VARCHAR2,
                               GroupBy  IN VARCHAR2) RETURN VARCHAR2 IS
       BEGIN
          RETURN 'SELECT tiin.kampkod,
                 tiin.abnr,
                 tiko.fordsalj,
                 MAX(tici.regdat) ALARMDATE
            FROM tis.tiin
            JOIN tis.tiko ON tiin.kampkod = tiko.kampkod
                         AND tiin.abnr = tiko.abnr
            JOIN core.tici ON tiin.kampkod = tici.kampkod
                          AND tiin.abnr = tici.abnr
                          AND tici.inplnr = tiin.inplnr
           WHERE 1 = 1 ' || SqlWhere || ' GROUP BY ' || GroupBy;
       END fnc_cSqlSelect;
    
    BEGIN
       -- If these parameters are null, raise error
       IF psUppgkedjetyp IS NULL AND psSubtyp IS NULL THEN
          raise_application_error(-20001,
                                  'Either Event Chain or Starting Event must be assigned');
       END IF;
       -- Populate TIAL values
       IF psUppgkedjetyp IS NOT NULL THEN
          cTIAL.Uppgkedjetyp := psUppgkedjetyp;
       END IF;
       --
       IF psAlarmtyp IS NOT NULL THEN
          cTIAL.Alarmtyp := psAlarmtyp;
       END IF;
       --
       cTIAL.Handklass := 'T';
       cTIAL.Blobid    := 0;
       --
       IF pnDays IS NOT NULL THEN
          psDays := '+ ' || pnDays;
       END IF;
       IF psSubtyp IS NOT NULL THEN
          cTIAL.Subtyp := psSubtyp;
       END IF;
       -- Create Where clause for cursor
       vSqlWhere := '';
       IF psKampkod IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.kampkod = ''' || psKampkod || '''';
       END IF;
       --
       IF psKatnr IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.katnr = ''' || psKatnr || '''';
       END IF;
       --
       IF psUtgava IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.utgava = ''' || psUtgava || '''';
       END IF;
       --
       IF psKatslag IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tikg.katslag = ''' || psKatslag || '''';
       END IF;
       --
       IF psProdsyst IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tikg.prodsyst = ''' || psProdsyst || '''';
       END IF;
       --
       IF psUppgtyp IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.uppgtyp = ''' || psUppgtyp || '''';
       END IF;
       --
       IF psProdkod IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.prodkod = ''' || psProdkod || '''';
       END IF;
       --
       IF psStatus IS NOT NULL THEN
          vSqlWhere := vSqlWhere || ' AND tiin.status = ''' || psStatus || '''';
       END IF;ç
       -- Loop through all records meeting input parameters and set required TIAL values.
       OPEN cSelectCursor FOR fnc_cSqlSelect(vSqlWhere,
                                             vGroupBy);
    
       LOOP
          FETCH cSelectCursor
             INTO v; -- You must define a variable 'v' to hold the data of cursor
          EXIT WHEN cSelectCursor%NOTFOUND;
    
          --FETCH cSelectCursor INTO cRec;
          cTIAL.Kampkod   := '';
          cTIAL.Abnr      := '';
          cTIAL.Sign      := '';
          cTIAL.Alarmdate := '';
          cTIAL.Kampkod   := i.Kampkod;
          cTIAL.Abnr      := i.Abnr;
          cTIAL.Sign      := i.fordsalj;
          cTIAL.Alarmdate := i.alarmdate;
          --
          nCount := nCount + 1;
          --
          IF vLopnr = -1 THEN
             raise_application_error(-20002,
                                     'Error Creating task for: ' || cTIAL.Kampkod || ' ' ||
                                     cTIAL.Abnr || ' Sales Rep: ' || cTIAL.Alarmdate);
          END IF;
       END LOOP;
    
       CLOSE cSelectCursor;
    
       DBMS_OUTPUT.PUT_LINE('I created ' || nCount || ' records.');
    
    END createFollowUpTask_Exposure;
    /
    

    Kind regards

  • Syntax of UPDATE of Oracle with the JOIN and the WHERE clause

    I need to update one of my paintings and can't seem to get the syntax right. I tried 4 different approaches, but does not have a chance.  Any help would be greatly appreciated.

    Attempt #1: Error: not correctly completed SQL command

    UPDATE TESTDTA.F4941
    SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM
    FROM TESTDTA.F4941
    INNER JOIN TESTDTA.F4981
    ON TESTDTA.F4941.RSSHPN  = TESTDTA.F4981.FHSHPN
    WHERE TESTDTA.F4941.RSSHPN = 647143
    AND TESTDTA.F4941.RSDSTN = 0
    AND TESTDTA.F4941.RSADDJ  > 110365
    AND TESTDTA.F4981.FHCGC1  = 'DIS';

    Try #2: Error report: SQL error: ORA-00904: "TESTDTA." "" F4981 ". "' FHUOM ': invalid identifier 00904. 00000 - '% s: invalid identifier '.

    UPDATE (SELECT TESTDTA.F4941
    FROM TESTDTA.F4941
    INNER JOIN TESTDTA.F4981
    ON TESTDTA.F4941.RSSHPN  = TESTDTA.F4981.FHSHPN
    WHERE TESTDTA.F4941.RSSHPN = 647143
    AND TESTDTA.F4941.RSDSTN = 0
    AND TESTDTA.F4941.RSADDJ  > 110365
    AND TESTDTA.F4981.FHCGC1  = 'DIS')
    SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM


    Try #3: Error report: SQL error: ORA-00904: "TESTDTA." "' F4941 ': invalid identifier 00904. 00000 - '% s: invalid identifier '.

    UPDATE (SELECT *
    FROM TESTDTA.F4941
    INNER JOIN TESTDTA.F4981
    ON TESTDTA.F4941.RSSHPN  = TESTDTA.F4981.FHSHPN
    WHERE TESTDTA.F4941.RSSHPN = 647143
    AND TESTDTA.F4941.RSDSTN = 0
    AND TESTDTA.F4941.RSADDJ  > 110365
    AND TESTDTA.F4981.FHCGC1  = 'DIS')
    SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM;


    Try #4: Error: ORA-00925: Missing keyword 00925. 00000 - "missing IN the keyword"

    MERGE TESTDTA.F4941
    USING TESTDTA.F4981
    ON (TESTDTA.F4941.RSSHPN  = TESTDTA.F4981.FHSHPN
    AND TESTDTA.F4941.RSSHPN = 647143
    AND TESTDTA.F4941.RSDSTN = 0
    AND TESTDTA.F4941.RSADDJ  > 110365
    AND TESTDTA.F4981.FHCGC1  = 'DIS'
     
    )
    WHEN MATCHED THEN
    UPDATE SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ
      
    ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM;

    Finally managed to do work, adding DISTINCT to select.  I have pasted the SQL error in Google to begin with.  Laughing out loud!

    Code snippet work for anyone who comes across this thread...

    MERGE INTO TESTDTA. F4941 DST

    USING (SELECT DISTINCT TESTDTA. F4941. RSSHPN,

    TESTDTA. F4941. RSDSTN,

    TESTDTA. F4941. RSUMD1,

    TESTDTA. F4941. RSADDJ,

    TESTDTA. F4981. FHSHPN,

    TESTDTA. F4981. FHRTDQ,

    TESTDTA. F4981. FHUOM,

    TESTDTA. F4981. FHCGC1

    OF TESTDTA. F4941

    JOIN INTERNAL TESTDTA. F4981

    ON TESTDTA. F4941. RSSHPN = TESTDTA. F4981. FHSHPN

    WHERE - TESTDTA. F4941. RSSHPN = 647143 AND

    TESTDTA. F4941. RSDSTN = 0

    AND TESTDTA. F4941. RSADDJ > 110365

    AND TESTDTA. F4981. FHCGC1 = 'SAY') CBC

    on (DST. RSSHPN = SRC. FHSHPN)

    When matched then update

    SET DST. RSDSTN = SRC. FHRTDQ, SUMMER TIME. RSUMD1 = SRC. FHUOM;

    Thanks to everyone who helped with this.

  • left outer join and the where clause for the table to the right

    I want to join two tables a and b, where a is a must and b is a result set in option. When I use a left outer join to a to b, I want to achieve:

    1. Select a single column, two columns of b (not the join columns)
    2 - even if theres no friendly on the join column does not return data from one.
    3. If there is a match applies when the criteria on column b (table in option)

    so, how can I avoid no_data_found in this case? When I apply where criteria for b, so it does not return the data from one, which is a must.

    Sounds like a regular outer join to me...

    select a.col1, b.col2, b.col2
    from   tableA a
           left outer join tableB b
           on (a.id = b.id and b.colX = 'X')
    
  • Virtual Center Version 2.5.0 Build 119598 - add user / Select user GUI - not finding the users accounts and groups in Microsoft AD

    All,

    Has anyone seen the following symptoms?

    (1) when a user or group account does not appear in the 'users and groups' dialogue box 'Select users' research will result in a "select users or groups" pop indicating "no user or group not found as the search result. Before beginning your search, in the dialog box "Select users", the correct domain name appeared in the "domain:" drop-down list.

    (2) not possible to account or group of usernames containing spaces. She will accept the format of the name of groups 'Pre-windows 2000' of objects. The account names and groups ' select users ' GUI will be find the account or group when you enter the explicit & lt; domain name & gt; ------& lt; Account name & gt; in the text box 'Users' or & lt; domain name & gt; ------& lt; Group name & gt;.

    Is there a known issue with user accounts or to find when they do not appear in the "users and groups" in the dialog box "select users".

    Kind regards

    Steve

    Sorry, wrong forum, this is Server 2.0.

    ---

    If you have found this device or any other answer useful please consider the use of buttons useful or Correct to award points.

  • tables, join and summation

    Hello everyone, I wrote a query for this but unfortunately it does not work...

    I have two tables

    Table 1

    amount used_date
    29/12/2006 4
    30/12/2006 3

    Table 2
    amount used_date
    29/12/2006 5
    30/12/2006 6

    Now, I have to join the two table and get the total sum of the amount... so the result should be... I have

    final table
    amount used_date
    18 2006

    I have problems with writing a query to do this, I'm still a beginner please note.

    Thank you.

    I guess that you do not want to join the tables, but combine all records on their part
    and calculate a total per year

    WITH TABLE_1 AS(
      SELECT  TO_DATE('12/29/2006', 'mm/dd/yyyy')  USED_DATE,  4 AMOUNT FROM DUAL UNION ALL
      SELECT TO_DATE('12/30/2006', 'mm/dd/yyyy') , 3 FROM DUAL
    ),
    TABLE_2 AS(
      SELECT  TO_DATE('12/29/2006', 'mm/dd/yyyy')  USED_DATE,  5 AMOUNT FROM DUAL UNION ALL
      SELECT TO_DATE('12/30/2006', 'mm/dd/yyyy') , 6 FROM DUAL
    )
    SELECT extract(YEAR from used_date) year, SUM(AMOUNT)
    FROM (
      SELECT * FROM TABLE_1
      UNION ALL
      SELECT * FROM TABLE_2
    )
    GROUP BY extract(YEAR from used_date)
    ;
    
    YEAR                   SUM(AMOUNT)
    ---------------------- ----------------------
    2006                   18                     
    
  • Interface SQL and Group By

    Is it possible to use the Group By clause in the SQL interface or what I need to create a view in the data source with the group required to achieve this?

    You can simply drop your entire sql statement in the first box. Ignore others in the State of charge of sql.

    I tend to develop my sql scripts in another tool (like the toad) and then copy and paste the script into the charge status select box (you need to remove the word "select" in your statement). This way you can make order bys, joins, all you want.

    Published by: Sean V on March 10, 2009 08:25

  • How can I remove an item from the death of the select icons and notifications appear in the taskbar?

    When I open "Select icons and notifications appear in the task bar" one of the things it lists is "GLBD565.tmp" which seems to be left by the installation of a software product.  The icon is not active and I doubt if it still exists, but it appears in the list.  That list is maintained and how to remove the dead of her spots?

    The entries to Customize Notifications cannot be removed selectively. You can, however, clear the set lists by using the following registry change.

    1. Click Start, type regedit in the Search box and press ENTER.

    2. Locate and then click the following registry subkey:
      Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify HKEY_CURRENT_USER
    3. In the Details pane, click the IconStreams registry entry.
    4. On the Edit menu, click delete, and then click Yes.
    5. In the Details pane, click the PastIconsStream registry entry.
    6. On the Edit menu, click delete, and then click Yes.
    7. Exit Registry Editor.
    8. Restart the Explorer.exe process. To do this, follow these steps:
    9. Press CTRL + SHIFT + ESC.
    10. On the process in the Task Manager tab, click the process explorer.exe and then double click on end process .
    11. On the file menu, click new task (run), type Explorer and click OK.
    12. Exit Task Manager.

    (c) Microsoft Corporation

    -or-

    Download and run a VBScript script that automates the steps above.
    How to delete items from the Notification area in Windows 7/Vista/XP

    Ramesh Srinivasan, Microsoft MVP [Windows Desktop Experience]

  • Message: Need IPv6 to join the Group of home when he tried to join the group home

    Original title: IPv6

    When I try to join a homegroup on this computer, I get a message that says I need IPv6. I clicked on the adapter and went to proberties and I have IPv6 installed and it has a check mark in the box. So, it should work. When I clik on the link and go to properties and don't look at the IPv6 connection it say no internet. What this means and how to get it to connect. Man this is proving to be a mess.

    Hi billgoodwin,

    Try the steps mentioned by "Novak Wu MSFT, Moderator Monday, November 2, 2009 01:06" and check the result. See IPv6 must join home group

    For reference, see why I can't join a homegroup?

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Not the users and groups folder under computer management

    Original title: no access to users and groups in Windows 8 Pro

    Right click on computer, select Manage

    There is no option in the management of the computer!

    WHY? How to view?
    Thank you
    Hi Johnny,.
     

    Looks like you are unable to get users and groups under computer management.

     
    I would like to gather information to help you:
     

     
    (1) how do you try to locate users and groups under computer management?
    (2) you are able to view other folders in the same section?
    (3) don't you make changes to the computer before this problem?

     
    I suggest you to check if the steps will help you to locate users and groups folder under Computer Management:
     

    (a) Windows and X set button, and then select computer management.
    (b) double click on system tools.
    (c) click on local users and groups.
    (d) check if you are able to find users and groups folder.
     
    Do we not respond with the status of this issue.
  • Analytical and group functions of

    Oracle 11g Release 2 Server

    SQL, SQLPLUS not

    I need to 'break' when a column value changes and insert a line with only a dash.

    CREATE TABLE tab
    (   id            number
      , part_num      number
      , part_type_id  number
      , part_type_txt varchar2(50)
      , CONSTRAINT tab_pk PRIMARY KEY(part_num,part_type_id)
    )
    /
    
    insert into tab values(1,10,100,'hose') ;
    insert into tab values(1,10,110,'hose clamp') ;
    insert into tab values(1,20,200,'plastic value') ;
    insert into tab values(1,20,210,'brass value') ;
    insert into tab values(1,30,300,'headlamp') ;
    insert into tab values(1,30,310,'lamp misc') ;
    commit ;
    
    select part_num,part_type_id,part_type_txt, count(part_num) CNT
    from   tab
    where  id = 1
    group by part_num,part_type_id,part_type_txt
    order by part_num,part_type_id ;
    
      PART_NUM PART_TYPE_ID PART_TYPE_TXT       CNT
    ---------- ------------ ------------------- ----------
            10          100 hose                         1
            10          110 hose clamp                   1
            20          200 plastic value                1
            20          210 brass value                  1
            30          300 headlamp                     1
            30          310 lamp misc                    1
    

    My query:

    WITH   data
    AS
    (
       select   case when nvl( lag( part_num ) over( order by rownum ), ' ' ) != part_num
                     then part_num
                end part_num
             ,  part_type_id, part_type_txt, count(part_num) CNT
       from
                tab
       where    id = 1 
       group by    case when nvl( lag( part_num ) over( order by rownum ), ' ' ) != part_num
                        then part_num
                   end 
                 , part_type_id
                 , part_type_txt
       order by part_num,part_type_id 
    )
    SELECT rownum, d.part_num,d.part_type_id, d.part_type_txt
    FROM   data   d ;
    
    ERROR at line 11:
    ORA-30483: window  functions are not allowed here
    
    
    

    I guess that analytical functions are not allowed in a group by clause.

    Output desired, he had to 'break' on when PART_NUM changes and insertion of a line with a dash (-):

      PART_NUM PART_TYPE_ID PART_TYPE_TXT       CNT
    ---------- ------------ ------------------- ----------
            10          100 hose                         1
            10          110 hose clamp                   1
            -
            20          200 plastic value                1
            20          210 brass value                  1
            -
            30          300 headlamp                     1
            30          310 lamp misc                    1
    

    Any help appreciated.

    Hello

    I see: XYZ123 is linked only to a part_type_id, 7777, so you do not want any output to XYZ123.

    Similarly, XYZ456 is only linked to a part_type_id, 8888, so you do not want XYZ456.

    One thing you can do is to start with the query in response to #4 above.  The results of this query, you can count part_type_ids h: different lots, each part_num is bound to and then only display the part_nums who have more than 1 part_type_id.  For example:

    WITH got_aggregates AS

    (

    SELECT THE CHECK BOX

    WHEN you GROUP (part_type_id) = 0

    THEN TO_CHAR (part_num)

    ELSE '-'

    END                               AS txt

    part_type_id, part_type_txt

    CASE

    WHEN you GROUP (part_type_id) = 0

    THEN COUNT (part_num)

    END                               AS cnt

    part_num,

    COUNT (DISTINCT part_type_id)

    COURSES (PARTITION BY part_num) AS part_type_id_cnt

    TAB

    ID WHERE = 1

    GROUP BY part_num, ROLLUP (part_type_id, part_type_txt))

    )

    SELECT txt, part_type_id, part_type_txt, cnt

    OF got_aggregates

    WHERE part_type_id_cnt > 1

    ORDER BY part_num, part_type_id

    ;

    Note that the subquery got_aggregates is almost identical to the response query #4.  The only differences are that the subquery is not an ORDERBY clause (ORDER BY is almost always useless to subqueries) and includes two additional columns, which will be needed in the WHERE and ORDER BY the main query clauses.

  • How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?

    n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a IDENTITY column. Even if the INSERT... SELECT statement works on most SELECT uses I tried, if this statement was also a GROUP BY clause, it does not work, delivering a "ORA-00979: not a GROUP BY expression ' complaint. Some examples of code:

    create table aux ( owner_name varchar2(20), pet varchar2(20) ); 

    insert into aux values ('Scott', 'dog');

    insert into aux values ('Mike', 'dog');

    insert into aux values ('Mike', 'cat');

    insert into aux values ('John', 'turtle'); 


    create table T1 (

    id number generated always as identity,

    owner_name varchar2(20),

    pet_count number );

    select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine

    insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work

    The select statement works by itself, but it fails as an INSERT... SELECT statement.

    Appreciate the help!

    Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:

    SQL > insert into T1 (owner_name, pet_count)
    2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
    3. Select owner_name, pet_count t
    4.

    3 lines were created.

    SQL > select * from t1;

    ID OWNER_NAME PET_COUNT
    ---------- -------------------- ----------
    1 John                          1
    Scott 2 1
    3 Mike                          2

    SQL >

    Keep in mind index THAT MATERIALIZE is undocumented.

    SY.

Maybe you are looking for

  • Blue overlay in all photos on Satellite L550

    I bought a L550 a week ago and everything is great, except the dominant blues on all photos.I use the Viewer for Microsoft Windows 7, ADOBE Elements, browser from Canon and Olympus Master 2...The major blue color is not obvious in the "examples of ph

  • VS 2010 pro, I can load up on more than one pc?

    I bought professional visual studio 2010 can I load it on several pc. That is the office and cell phones

  • lots.ini

    Hi, I have my windows xp sp3 all readers have a text file called lots.ini how to pick up there is not another

  • phone call from aledged rep of window on viruses

    I just got a phone call from a person claiming from windows. She said he had a virus attacking the hard drives and that she wished to have access to my computer but I said I don't l, t have it and she'll call later is this illgit.

  • M14x R1 camera / microphone does not

    Hello I installed windows 7 on my PC and installed all the drivers present on the Dell CD, but my camera and microphone don't work anymore... I tried to install the driver: "Dell Alienware M14x caméra Firmware, v.1627, A01" but he said: "no device! I