Adding the results of subqueries, where one subquery returns no rows

I am creating a complex SQL statement- many of the columns consist of the sum of two subqueries. Here is a simplified example:
SELECT NAME, ID,
(SELECT AMT1 FROM TABLE1 WHERE ID = 111) + (SELECT AMT2 FROM TABLE2 WHERE ID = 222),
(SELECT AMT3 FROM TABLE3 WHERE ID = 333) + (SELECT AMT4 FROM TABLE4 WHERE ID = 444),
FROM TABLE
WHERE...
The problem is, within one select item, if one subquery returns no rows and the other returns a row of data, the sum of the two is displayed as zero. For example, if 'SELECT AMT1 FROM TABLE1 WHERE ID = 111' returns a row, with a value of AMT1 = 1000, and 'SELECT AMT2 FROM TABLE2 WHERE ID = 222' returns no rows, the result is displayed as 0, not 1000. It reminds me of when you add a number and a NULL, and get NULL - the number gets ignored.
Is there a way to embed some conditional logic in the subquery, to say 'if no rows returned, AMT = 0, else AMT = value'? Any help would be appreciated.

Yikes, you appear to have stumbled upon DMFH!
You can use NVL like this -
SQL> select
  2    (select 1 from dual) + (select 2 from dual) x
  3  from dual;
         X
         3
SQL> edi
Wrote file afiedt.sql
  1  select
  2    (select 1 from dual) + (select 2 from dual where 0 = 1) x
  3* from dual
SQL> /
         X
SQL> edi
Wrote file afiedt.sql
  1  select
  2    (select 1 from dual) + nvl((select 2 from dual where 0 = 1),0) x
  3* from dual
SQL> /
         X
         1
SQL>(DMFH = Data Model From Hell)

Similar Messages

  • HT4059 when i click my iphone books tab dsnt appear on the resulting window so where should i drag my pdfs

    when i click my iphone books tab dsnt appear on the resulting window so where should i drag my pdfs

    What happens if you go to iTunes > File > Devices, do you get the option to Sync iPhone?
    You could try a reinstall of iTunes. OS X Yosemite: Reinstall apps that came with your Mac

  • Subquery returns 0 rows-----HELP

    I need to understand something.
    please follow my points:-
    1-If we try to make a NOT IN condition, and one value is NULL, the main query return no result, because the NOT IN condition evaluates to FALSE "NULL" "UNKNOWN".
    example:-
    SELECT 'True' FROM employees
    WHERE department_id NOT IN (10, 20, NULL);
    this query returns no rows, simply because the condition is parsed like this
    department_id != 10 AND department_id != 20 AND department_id != null
    ^^^I have no question regarding this point and it is quite obvious.
    2-If the subquery returns 0 rows, then the value of the scalar subquery expression is NULL.
    example:-
    create table subq_null_test
    num number(4),
    val varchar2(7)
    insert into subq_null_test
    values (1,'one');
    insert into subq_null_test
    values (2, (select 'two' from dual where 2=1));
    insert into subq_null_test
    values (3, 'three');
    commit;
    and by
    select * from subq_null_test;
    we would see a NULL inserted as value for number 2
    NUM VAL
    1     one
    2     (null)
    3     three
    so far so good, indeed the 0 row subquery returned NULL
    ^^^Also I CAN'T have a point here.
    ============================================
    but lets look at these 3 queries
    -------->FIRST
    select department_id, last_name
    from employees
    where department_id not in (10,20,null)
    /*no rows selected*/
    --------->SECOND
    select department_id, last_name
    from employees
    where department_id not in (10,20,(select 10 from dual where 2=1))
    /*no rows selected*/
    -------->THIRD
    select department_id, last_name
    from employees
    where department_id not in (select 10 from dual where 2=1)
    /*ROWS returned*/
    my question is:-
    WHY FIRST and SECOND queries behaved as expected, while the THIRD didn't ???
    -I had a look at the execution plan, and it didn't helped me "am a beginner anyways"
    -I know its something related to the process or parsing the conditions, but am totally unable to locate it...
    Any help would be so much appreciated,
    Thanks for all.
    Ghazal.

    Hi again
    Yes; while I was writing my reply, you corrected it.Now it seems like you're making the same mistake again.I believe I had clarified it enough.
    Once again, I was only talking about the situation where department_id is NULL.Of course "x IN y" can be TRUE, FALSE or UNKNOWN, depending of what x and y are. All I was saying is that "NULL IN y" can be FALSE (depending on y), even though "NULL = q" is always UNKNOWN, regardless of what q is, and I find that a little inconsistent.-now we are on the same side "I hope :)...jk"...well yea we are talking about the department_id "left-hand" operand is NULL.
    -Regarding YOUR point, I can't agree with you Sir.
    I see it pretty much consistent that when the left-hand operand is NULL,,,it is always UNKNOWN even if the right-side operand is a null.
    I would even go further and say if there is a using of word "regardless", it wold be like this
    if the left-hand operand is NULL the condition evaluates to UNKNOWN no matter what is in the right-hand operand REGARDLESS what condition we are using IN or NOT IN.
    so
    "x IN y" can be TRUE, FALSE or UNKNOWN, depending of what x and y are. All I was saying is that so far so good
    "NULL IN y" can be FALSE (depending on y), even thoughNo, it is ALWAYS UNKNOWN 'you can call is FALSE'.
    "NULL = q" is always UNKNOWN, regardless of what q is, and I find that a little inconsistent.I find it okay.
    -"NULL = q" is always UNKNOWN regardless of what q is, is perfect and consistent indeed.
    -"NULL in (q, p, d)" is always UNKNOWN.
    -"NULL NOT in (q, p, d)" is always UNKNOWN.
    I would again dare and go further and say
    -whenever we have NULL on the left-hand operand
    result of the condition is only 2 cases and can never be 3
    1-UNKNOWN :- if we use "=, !=, IN, NOT IN, or anything may exists"
    2-TRUE :- if we use "IS"
    -this case of NULL as our left-hand operand can never have a FALSE case...
    ORACLE does do this for us by her own, and thanks ORACLE for that...alot.
    select 'BANG' from dual where null is null;
    select 'BANG' from dual where (select department_id from employees where last_name = 'kokolala') in (10,20, null);
    select 'BANG' from dual where (select department_id from employees where last_name = 'kokolala') is null ;This all is perfect, consistent, logical and cute.
    Solomon Yakobson : Think about the dirrerence between empty list and list containing a null element.This is cool, correct. this is the actual solution to the matter of having a null in our right-hand operand "BY JUST IGNORING THE NULLS, and is the list have only nulls it becomes an empty list", but in our case we do NOT have an EMPTY list, we have a list with a NULL indeed.
    -ORACLE just under the hood did us a favor of giving us an EMPTY list by ignoring the nulls using "LNNVL", which is doing no good..let him experience it, let him taste it, let him avoid it, him him him design it. and do not give me an inconsistent mechanism. it is good to sell that ORACLE is treating results as lists but that shouldn't intervene with our system-level language, am boooring guy, if its designed to work like this, no am sorry it should be stopped now.
    My point is
    -This theory is great regarding the matter when we are talking about dealing with our result as a LIST of elements, we would take in consideration our NULL values, which what SHOULD be implemented by the coder.
    -BUT the issue of oracle implements "LNNVL" while parsing our codes INCASE and ONLY in the case of subquery as our right-hand operand, I am not buying it and i see it inconsistent.
    They should implements it in all cases, or not at all "not even in one case as an exception", this is logic and it cant be divided or argued.Am still hoping someone have an explanation to the matter, I wouldn't like it at all to know that am 100% correct in my analysis of this case, because if I am I would like to see them changing it.
    Edited by: Ghazal-OCA on Jan 8, 2013 7:04 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:10 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:19 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:20 AM
    Edited by: Ghazal-OCA on Jan 8, 2013 7:23 AM

  • When subquery returns multiple rows

    I have a doubt in this case. I follow Oracle SQL by example book and I find that "<=" is used in this query.
    He says that when the subquery returns single row,,only then <=, >=, = should be used..
    Why did they not use ANY,ALL or SOME operators.....When I use ANY,ALL ,,,it gives me an error "Invalid Relational operator"...... Please help
    select c.description, s.section_no, c.cost, s.capacity
    from course c, section s
    where c.course_no=s.course_no
    and s.capacity <= (select avg(capacity) from section)
    and c.cost=(select min(cost) from course)

    Hi,
    user11090588 wrote:
    I have a doubt in this case. I follow Oracle SQL by example book and I find that "<=" is used in this query.
    He says that when the subquery returns single row,,only then <=, >=, = should be used..
    Why did they not use ANY,ALL or SOME operators.....If the sub-query returns no more than 1 row, then it doesn't matter which, if any, of the keywords ANY, ALL or SOME you use: they all give the same results. Only when there are 2 or more rows can it matter if you're doing the comparison to any, all or some of the rows.
    When I use ANY,ALL ,,,it gives me an error "Invalid Relational operator"...... Please help
    select c.description, s.section_no, c.cost, s.capacity
    from course c, section s
    where c.course_no=s.course_no
    and s.capacity <= (select avg(capacity) from section)
    and c.cost=(select min(cost) from course)If the problem occurs when you use ANY or ALL, why not post a query where you use ANY or ALL?
    Post a complete script that people can use to re-create the problem and test their ideas. That includes CREATE TABLE and INSERT statements for your tables (unless you can show the problem using commonly available tables, like those in the scott schema).
    Always say which version of Oracle you're using.
    I can't reproduce the problem. I don't get any error using ANY, ALL, SOME or nothing before either sub-query:
    SELECT     d.deptno
    ,     e.ename
    ,     e.sal
    FROM     scott.dept     d
    JOIN     scott.emp     e  ON     d.deptno     = e.deptno
    WHERE     e.sal  <= ANY (
                   SELECT  AVG (sal)
                   FROM     scott.emp
    AND     d.deptno = SOME (
                       SELECT  MIN (deptno)
                       FROM    scott.dept
    ;Output from the query above:
    `   DEPTNO ENAME             SAL
            10 MILLER           1300I'm using Oracle 10.2.0.1.0.
    Don't worry too much about ANY, ALL or SOME before sub-queries. I've never seen them used outside of a textbook (or questions like this, taken from a textbook). In real life, nobody uses them.
    Someone once showed me any example where one of these actually would be useful if you didn't have analytic functions, but I didn't note what it was, or where I saw it. Analytic functions were introduced in Oracle 8.1, so that's only of historical interest now.

  • The simplest way for plsql procedure to return multiple rows

    Hi,
    What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
    Sample query would be: SELECT * FROM EMPLOYEES;
    I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
    It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
    Thank you!

    Hi,
    It depends :-).
    With +...that is appropriate for plsql beginners...+ in mind... it still depends!
    The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
    +Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
    What is the level of "programming experience" ?
    What is the level of understanding of "Relational Result set" as processible in Oracle?
    If you are looking for
    Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
    I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
    So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
    vr,
    Sudhakar B.

  • DECODE is not working in WHERE clause when subquery returns more rows

    Hi Gurus,
    I want to write a query on CCENTERS table(Script given below) and expect the following result:
    1. When I pass a value of 0 for ID, It returns all the rows given in the table.
    2. When I pass a value other than 0, It returns the row for the given value as well as all its child records.
    CCENTER has parent-child relationship in ID and BASE column. I am using a query with DECODE function. but DECODE function in WHERE clause is not capable of handling sub-query with multiple rows.
    VARIABLE ParaCCenter NUMBER
    BEGIN
    :paraccenter:=0;
    END;
    CREATE TABLE ccenters
    (id NUMBER,
    name VARCHAR2(20),
    base number);
    INSERT INTO ccenters VALUES(1,'NUST',null);
    INSERT INTO ccenters VALUES(2,'SEECS',1);
    INSERT INTO ccenters VALUES(3,'NBS',1);
    commit;
    SELECT * FROM ccenters
    WHERE id IN DECODE(:ParaCCenter, 0, id,
    (SELECT id FROM ccenters
    START WITH base=:ParaCCenter
    CONNECT BY PRIOR id = base
    UNION
    SELECT :ParaCCenter FROM dual
    BEGIN
    :paraCCenter:=1;
    END;
    SELECT * FROM ccenters
    WHERE id IN DECODE(:ParaCCenter, 0, id,
    (SELECT id FROM ccenters
    START WITH base=:ParaCCenter
    CONNECT BY PRIOR id = base
    UNION
    SELECT :ParaCCenter FROM dual))
    The result is
    (SELECT id FROM ccenters
    ERROR at line 3:
    ORA-01427: single-row subquery returns more than one row
    How this query can be rewritten for the given functionality. Any response will be highly appreciated.
    Thanks

    And if you want to use DECODE:
    SQL> BEGIN
      2  :paraccenter:=0;
      3  END;
      4  /
    PL/SQL procedure successfully completed.
    SQL> select  *
      2    from  ccenters
      3    where :paraccenter = decode(:paraccenter,0,0,id)
      4  /
            ID NAME                       BASE
             1 NUST
             2 SEECS                         1
             3 NBS                           1
    SQL> BEGIN
      2  :paraccenter:=2;
      3  END;
      4  /
    PL/SQL procedure successfully completed.
    SQL> select  *
      2    from  ccenters
      3    where :paraccenter = decode(:paraccenter,0,0,id)
      4  /
            ID NAME                       BASE
             2 SEECS                         1
    SQL> SY.

  • UPDATE TABLE - subquery returns multiple rows

    Hi,
    i need to update a table, but I don't know how or what I'm doing wrong.
    My syntax:
    UPDATE     TBL2
    SET TBL2.QUANTITY =
    (select     TBL1.QUANTITY
    from     TBL2,
         TBL1
    where TBL1.ID_STOCK=TBL2.ID_STOCK
    and     TBL1.DATE=TBL2.DATE
    and     TBL1.ID_FK_STOCKAREA=TBL2.ID_FK_STOCKAREA
    and     TBL1.ID_FK_STOCKPLACE=TBL2.ID_FK_STOCKPLACE
    and TBL1.ID_FK_CONTAINER=TBL2.ID_FK_CONTAINER
    AND TBL1.ID_STOCK = :P302_ID_STOCK)
    Acutally, it is only possible, that it returns only 1 value... but it always says: ORA-01427: subquery returns more than one row.
    Has anybody an idea??
    Thanks sooooo much,
    yours
    Elisabeth

    This might help:
    UPDATE TBL2
    SET TBL2.QUANTITY =
      select TBL1.QUANTITY
      from TBL1
      where TBL1.ID_STOCK=TBL2.ID_STOCK
      and TBL1.DATE=TBL2.DATE
      and TBL1.ID_FK_STOCKAREA=TBL2.ID_FK_STOCKAREA
      and TBL1.ID_FK_STOCKPLACE=TBL2.ID_FK_STOCKPLACE
      and TBL1.ID_FK_CONTAINER=TBL2.ID_FK_CONTAINER
      AND TBL1.ID_STOCK = :P302_ID_STOCK
    )pratz

  • ...where like ('% query returning mul rows %') - how?

    Hi
    I have a situation where in my main query's where clause I have to use like ('% <value returned from query2>%'). However, my query2 can return multiple rows.
    It is something like this:
    Select .....
    from table1 t1
    where path like ('%<query2>%').
    Path can have multiple values - it is just representing a parent child relationship like 1/2/3. 1 is a parent of 2. 2 is a parnt of 3 and so on. What I get from query2 could be either of these. So I have to use like and not in. How may I achieve this?

    select lvl,
           Path
      from (select distinct level as lvl,
                   sys_connect_by_path(parent,'/') Path
              from table1 t1
            connect by prior child = parent)
    where instr(path,((select parent                                                                   --+
                          from (select parent, sm, rank() over (order by sm desc) r                       |
                                  from (SELECT parent, SUM(CT1) as sm                                     |
                                          FROM ((select parent,count(child) ct1                           |
                                                   from table1 t1                                         |
                                                  where group by parent                                   |
                                        -- end level 1)                                                   |
                                        UNION ALL                                                         |
                                        (select parent, count(child) ct2                                  | try to move this sub-query
                                           from table1 t1                                                 | at the FROM clause
                                          where child in --first level                                    |
                                                (select parent                                            |
                                                   from (select distinct parent,count(child) ct1          |
                                                           from table1 t1                                 |
                                                          where group by parent) q1)-- end level 1        |
                                                 group by parent))--MAIN SEL                              |
                         GROUP BY parent))                                                                |
                        where r =1))) > 0--end instr                                                    --+
       and lvl = 1
    you may try to move sub-queries in your WHERE clause to the FROM clause.
    Message was edited by:
    Warren Tolentino
    justin has the same idea :D

  • Is there an equivelent tool to the "placeholders" in quark where one...

    one has, lets say a statement on the bottom of every page in a 200 page manual. when one needs to change it, how would he/she set it up so they only have to change it once rather than 200 times.

    Ok, I got it to work using "assignments" pallete but there's a few more steps than I would have liked...It involves saving an .inca and an .incx on my desktop which are going to pile up as I intend to use this tool heavily with many blurbs, phone numbers etc. Less annoying but still - I have to manage wether I am checked in or checked out.
    A little more backround if interested. I am actually using xml to "share information" with the web team and other departments. For the most part that is working fine, but with xml rooted information in indesign, you can't duplicate that text if its not also duplicated in the XML file but thats exactly what I am trying to avoid. I am trying to implement a system where all of our data is in ONE place. When a writer or a lawyer change the paragraph and I get a new xml file. I can automatically update that paragraph in all of my many materials that have that paragraph. I can do that successfully with xml but when any one of those blurbs are used 2x in one document, well here we are. Now I got the whole thing to work yesterday between my xml file and the above "assignments" pallete work. But am having trouble doing it again. It doesnt really matter because the assignmnets thing is too complicated (but cool though!)
    i am surprised as heck though that the whole graphic design industry hasnt been screaming for a simple tool like this for a long time. Often times, we sit and cut and paste all day and that's how mistakes happen.
    (zwetterman, The Text Variable thing (if I had cs3) I don't think will work since I will definitely want to do this stuff with paragraphs etc.)

  • Queries - Adding New Fields in the Result Tab

    Hi,
         Can anyone explain me on adding the result columns in the resultField tab while creating a query, I don't understand the actual link between the bundle, resourceid and values that we give as a search criteria while looking up the result columns. I tried to replicate an existing query and it worked fine. But I don understand the actual working. Please help me acquire this understanding.
         Also What happens when we say CONTEXTID=CONTEXT(upp.acl). As theory says, it retrives the records relevent to currently logged in user but how.
         I am a beginner. Please help me on these.

    Sharmele,
    I would say it is partially correct.
    In <%CONTEXT(upp.acl)%>, upp.acl is the class ID for a given class.
    But the role of CONTEXT attribute is far more important. In a nutshell, we can say that by using the CONTEXT attribute, you ensure that the data users see in a report/query is only the data that they have access to. Here, by access, just the 'write' access in not implied. It also means 'View' access.
    And to answer your question : Yes, in order to find the Class ID of a class, you must browse through the Class Reference. Additionally, in the page that opens up on clicking RG on a business document, the value in the Name section is same as the Class ID of that class.
    Thanks
    Devesh

  • One question of the method have two chance to return the result.

    Hello All,
    I get a problem at present.The code is following.
    package com.ricky.test;
    public class Test {
         public static void main(String args[]) {
              System.out.println(kkk());
         public static int kkk() {
              int k = 0;
              try {
                   k += 2;
                   return k;
              } catch (Exception e) {
                   k++;
                   return k;
              } finally {
                   k += 5;
                   System.out.println("get Here");
                   return k;
    }why does the result is 7.Isn't it return at the "try" part? and my eclipse alarm that "finally block doesn't complete normally";
    thank you for your help!(I hope someone know my mean,because i'm not good at english. )

    if I change the method to :
    public static int kkk() {
              int k = 0;
              try {
                   k += 2;
                   return k;
              } catch (Exception e) {
                   k++;
                   return k;
              } finally {
                   k += 5;
         }the result is 2(just execute k += 2 and then return the result.)
    but if i change the method to
    public static StringBuffer kkk1() {
              StringBuffer result = new StringBuffer("1");
              try {
                   result = result.append("2");
                   return result;
              } catch (Exception e) {
                   result = result.append("3");
                   return result;
              } finally {
                   result = result.append("4");
                   // return result;
         }the result is 124(the finally block effect the result value)Why?
    Maybe is the result is the memory address.is that right?

  • How to display result in more than one jsp page

    Hi all,
    the result is a very large it will take more than one jsp page in this senario how we will display the result in more than one jsp page.
    Thanks in Advance.

    The magic word is "paging". Look around using this keyword.
    Basically it's all about subquerying, (eventually) caching and sublisting.

  • Name of ODI variable in the result of Oracle SELECT

    Hello,
    I seek to evaluate the contents of an ODI variable (VP) which is the result of SELECT with other ODI variables (V1, V2,…, Vn) in its contents.
    Currently, the result of this first variable (VP) returns the name of the variables (V1 to Vn) and not the value of these variables.
    For example :
    My variable VP is a select from oracle (SELECT FIELD_NAME FROM TABLE_NAME WHERE XXX = VALUE)
    The field FIELD_NAME contains "The #PROJECT.V1 is OK and the #PROJECT.V2 is KO".
    I want to replace the two variables by their values.
    Does there exist simple means of recovering the value of these variables instead of their names ?
    Else, do you have a solution of skirting knowing that there can be several variables (V1 to Vn) and that they can be different according to the cases ?
    I'm in ODI 10.
    Thank you in advance for your assistance,

    Thanks for your answer.
    The second solution isn't possible to us because we don't know which variables are included in the SELECT result. We can have many variables and it is not always the same variables.
    For the first solution, I try to find the link between the data of table SNP_VAR_DATA and a session (SESS_NO). Unfortunately, I do not arrive there.
    Can you how make ? And by which tables of ODI ?
    Thanks in advance,

  • I want to put a number in a cell and tell it to times by 2 and get the result as a total further along. Sorry couldn't find the answer in any tutorial.

    I want to put a number in a cell and tell it to times by 2 to give the result i another cell?  Sorry couldn't find the answer in any tutorial.

    Hi Caakie,
    Sounds like tou need some basic information.
    The best advice I can give someone new to Numbers (and to spreadsheets in general) is to download and read at least the first four chapters of the Numbers '09 User Guide. You'll find a download link in the Help menu in Numbers '09.
    When you want to start using more complicated formulas, you'll also need the iWork Formulas and Functions User Guide, available from the same menu.
    Regarding your question: "Can you just give me the string for B which is just add and C which is *2."
    What is to be added in "B"? What is to be multiplied by 2 in "C"?
    =2+3 will return the result 5.
    =A+B will return the sum of the numbers in column A and column B in the same row as the cell containing the formula. If either A or B contains a non-numerical value, the formula will return an error message.
    =3*2 will return the result 6.
    =A*B will return the product of the numbers in column A and column B in the same row as the cell containing the formula. If either A or B contains a non-numerical value, the formula will return an error message.
    Regards,
    Barry

  • How do I get iTunes 11 to work as the old iTunes did in this respect: after playing a song in one playlist, I click on another playlist, highlight a song, press play, and get the result of that song playing & that playlist continuing?

       How do I get iTunes 11 to work as the old iTunes did in this respect: after playing a song in one playlist, I click on another playlist, highlight a song, press play, and get the result of that song playing & that playlist continuing?  As it goes now, one clicks on the song in the new playlist where the arrow is and then chooses 'Play Song Next.'  So, it plays next, but then the song after that is back in the old playlist.  I want to use iTunes smoothly without the extra clicks I've had to do in order to get the playlist to continue.  This is music for background while I play the violin at restaurants, and extra clicks and hassle is quite unappreciated, especailly since it worked fine in the previous iTunes.
       Thanks.

    At the top of the playlist where it shows the playlist title and the number of songs, there are two icons. Click the "play" triangle to add the entire playlist to "Up Next", or the "shuffle" symbol to do the same thing but in random order. But the currently playing track will stop playing, and all the songs in "Up Next" will be removed (replaced by the ones from this playlist).
    If you hold down the "option" key while clicking those icons, the currently playing song will continue playing, and the new playlist will be added to "Up Next" (above the songs that were already there).

Maybe you are looking for