Distinct count in the instruction box

-------------------------------------------------------------------------------------------------
SELECT A.P_ID,
B.P_NAME,
C.P_DESC,

SUM (CASE
WHEN A.DATE BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE),-4) + 1) AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)),-1)
AND A.M_ID IS NOT NULL
THEN 1
0 OTHERWISE
END) AS COUNT,
SUM (CASE
WHEN A.DATE BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE),-4) + 1) AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)),-1)
AND A.M_ID IS NOT NULL
THEN COUNT (DISTINCT A.M_ID)
0 OTHERWISE
END) AS UNIQUE_COUNT, / * is not possible * /.
SUM (CASE
WHEN A.DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)), - 1).
THEN A.AMT_1
0 OTHERWISE
END) AS TOTAL_AMT_1,
SUM (CASE
WHEN A.DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)), - 1).
THEN A.AMT_2
0 OTHERWISE
END) AS TOTAL_AMT_2

FROM TABLE_A A,.
TABLE_B B,.
C TABLE_C


WHERE A.P_ID = B.P_ID
AND B.PT_ID = C.PT_ID
A.P_ID GROUP,
B.P_NAME,
C.P_DESC

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

Hello

It is a simplified version of my request.
I'm doing 4 things here,
1. the County A.M_ID
2 County has separate .M_ID, is where I have a problem.
3 and 4. It is just the sum of 2 diff columns.

Note that the dates for the County and the amt are different and I can't hard-code the.
Can someone help me step of distinct count?
This query runs also a bit slow.
So all suggestions, comments are welcome.
Note: TABLE_A REB 700 million, TABLE_B 4 million and TABLE_c is located only 500 RECS
Thank you!

Advantage of the fact that aggregate functions more ignore nulls, you could do something like:

SELECT a.p_id, b.p_name, c.p_desc,
       COUNT(CASE WHEN a.date BETWEEN TRUNC(ADD_MONTHS(LAST_DAY(sysdate),-4) + 1) AND
                                      ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) AND
                       a.m_id IS NOT NULL THEN m_id END) AS countall,
       COUNT(DISTINCT CASE WHEN a.date BETWEEN TRUNC(ADD_MONTHS(LAST_DAY(sysdate),-4) + 1) AND
                                    ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) AND
                     a.m_id IS NOT NULL THEN a.m_id END) AS unique_count, /* entirely possible */
       SUM(CASE WHEN a.date BETWEEN TRUNC(sysdate,'YEAR') AND
                                    ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) THEN a.amt_1
                ELSE 0 END) AS total_amt_1,
       SUM(CASE WHEN A.DATE BETWEEN TRUNC(sysdate,'YEAR') AND
                                    ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) THEN A.AMT_2
                ELSE 0 END) AS TOTAL_AMT_2
FROM table_a a, table_b b, table_c c
WHERE a.p_id = b.p_id and
      b.pt_id = c.pt_id
GROUP BY a.p_id, b.p_name, c.p_desc

The two statements inside the COUNTY box return a.m_id or NULL. A simplified test case is:

SQL> WITH t as (
  2     SELECT 1 m_id, 9 dt FROM dual UNION ALL
  3     SELECT 1 m_id, 6 dt FROM dual UNION ALL
  4     SELECT 2 m_id, 9 dt FROM dual UNION ALL
  5     SELECT 2 m_id, 6 dt FROM dual UNION ALL
  6     SELECT 1 m_id, 5 dt FROM dual UNION ALL
  7     SELECT 2 m_id, 5 dt FROM dual UNION ALL
  8     SELECT null m_id, 9 dt FROM dual)
  9  SELECT count(CASE WHEN dt BETWEEN 6 and 9 THEN m_id end) cid,
 10         count(distinct CASE WHEN dt BETWEEN 6 and 9 THEN m_id end) cdid
 11  FROM t;

       CID       CDID
---------- ----------
         4          2

I'm not entirely sure that you really need the IS NOT NULL predicate a.m_id in the instructions BOX, but I left it for more security.
John

Tags: Database

Similar Questions

  • Additive and Non-additive measures (Distinct Count) in the same Cube

    I am aware that you can create a cube with a single non-additive measure (distinct count) as explained in this article:

    https://www.Google.co.UK/URL?SA=t & rct = j & q = & esrc = s & source = web & cd = 3 & cad = AJLN & uact = 8 & ved = 0CDkQFjACahUKEwiFpJ3K0MnHAhXFbB4KHfH7BfU & url = http %3 has % 2F % www.vlamis.com%2Fstorage%2Fpapers%2F2013_732_claterbos_ppr.pdf 2F & ei = nDPfVYXmIMXZefH3l6gP and usg AFQjCNF6fSAuRqaRGR-nIAGOM9fEY08j7A

    However, my requirement is to have additive and not additive in the same cube, measures, as you can do with cubes MSAS.

    Is this possible with Oracle OLAP cubes?

    I see you mentioned you want to make in the same cube. What is a difficult requirement?

    If this isn't the case, you may want to explore using 2 cubes where the first cube do distinct count. The second

    cube can have your aggregation you want and a calculated measure that references the first cube

    kinda like a cube considered. The OLAP option did a good job supporting cubes and multiple clients

    set up what is called the cubes that reference other cubes of the basis of the declaration. The SQL code that question that the cubes can view (s)

    be attached so that you can select a plan of several cubes SQL query in a single query.

  • Problem with variable referencing of presentation (KEY Date) in the instruction box

    Hello

    I'm trying to reference variables of presentation created on a Date column in the instruction box to one of the columns in the query, as shown below:

    -case when '-citation details. "" "Created" between ' @{of} {1999-1-1}' and ' @{until} {2999-1-1} "then"-quote Metrics. " "" end of number of citations.

    I m getting a view displays error message with the following error message:

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 17001] Oracle error code: 1861, message: ORA-01861: literal does not match the format string to the call of the OIC OCIStmtExecute

    SQL issued: SELECT "-quote Types '." Name of level 2 Saw_0', case when '-citation details. "" Created "between" 01/04/2009 ' and ' 15 / 04/2009 ' then '-quote Metrics ' "." number of citations"end saw_1"(unit) - CATALOGUE of quotes"WHERE"-citation details "". "" Date of creation"BETWEEN timestamp ' 2009-04-01 00:00:00 ' timestamp AND ' 2009-04-15 00:00:00 ' ORDER BY saw_0


    When I created the prompt on the date field, I put the following in the command prompt:
    Cast ("-time".) Day)

    When I apply a filter on the query using these variables, it works fine.

    If anyone has faced this kind of question earlier and have a resolution, please help me.

    Thank you
    Kitenge

    Hello.

    Select the double - A NON-VALIDE MONTHS TO_DATE('1999-1-1','mm/dd/yyyy')

    Try this:

    OLD: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {1999-1-1} ", mm/dd/yyyy)
    NEW: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {01/01/1999} ", mm/dd/yyyy)

    and

    OLD: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {2999-1-1} ", mm/dd/yyyy)
    NEW: EVALUATE ('TO_DATE (%1, %2)', ' @{of} {1, 1, 2999} ", mm/dd/yyyy)

    and if not ok after that, after an error in query SQL of NQQuery.log.

    Kind regards

    Goran Ocko

    http://108obiee.blogspot.com/

  • need help in the instruction box

    Dear experts,

    IM using oracle 11g

    CREATE TABLE PAYLOG

    (

    ID VARCHAR2 (20).

    DESCRIPTION VARCHAR2 (20)

    );

    INSERT INTO PAYLOG VALUES ("1, ' NOT CAPTURED");

    INSERT INTO PAYLOG VALUES(2,'CAPTURED');

    INSERT INTO PAYLOG VALUES(3,'APPROVED');

    Here is the example output query example, I needed to know.

    SELECT THE CHECK BOX

    WHEN DESCRIPTION = 'CAPTURED' and 'APPROVED' - THEN when the captured data are currently it should display approved

    Where description = 'CAPTURED or APPROVED' then 'approved' - when the data "CAPTURED or APPROVED" is present then display approved

    When the description not in ("CAPTURED", "NO CAPTURE", "APPROVE") then 'rejected' - not in all these 3 data and then display rejected

    ) alias_name

    END

    OF PAYLOG;

    Now, I want to apply the same logic to query below

    with the temp as

    (

    Select

    (CASE

    DESCRIPTION = "NOT CAPTURED" THEN "rejected by the question.

    DESCRIPTION = "CAPTURED or APPROVED" then "APPROVED."

    WHEN NOT IN DESCRIPTION ("CAPTURED", "CAPTURED", "APPROVE") THEN 'OTHERS '.

    )

    snapshot_detail,

    Count (*) NTC, sum (payment_amnt) total

    of PAYLOG

    )

    Select snapshot_detail, sum (NTC) TOTAL_COUNT, sum (total) TOTAL_VALUE, round ((sum (NTC) / sum (NTC) over()) * 100.2) PERCENTAGE

    temp

    Group total, snapshot_detail, cnt

    Union of all the

    Select 'Total', sum (cnt), sum (total) TOTAL_VALUE, round ((sum (NTC) / sum (cnt)) * 100.2)

    temp

    Please help experts.

    What of this

    with temp as
    (
    select snapshot_detail, sum(cnt) cnt , sum(total) total
    from (
        select
          CASE
            WHEN DESCRIPTION        = 'NOT CAPTURED'                      THEN 'Rejected by Issue'
            when DESCRIPTION        = 'CAPTURED' or DESCRIPTION='APPROVED'            THEN 'APPROVED'  ----------------------------i want only one condition to be satisfied here
            WHEN DESCRIPTION NOT IN ('NOT CAPTURED','CAPTURED','APPROVED')THEN 'OTHERS'
          end snapshot_detail,
          count(*) cnt,
          sum(payment_amnt) total
        from paylog
        group by description )
    group by snapshot_detail
    )
    select snapshot_detail, sum(cnt) TOTAL_COUNT,sum(total) TOTAL_VALUE ,round((sum(cnt) / sum(cnt) over()) *100,2) PERCENTAGE
      from temp
     group by snapshot_detail ,total,cnt
    union all
    select 'Total', sum(cnt), sum(total) TOTAL_VALUE,round((sum(cnt) / sum(cnt)) *100,2)
    from temp;
    
  • Enum cohersion Dot on the instruction box

    Eveining.

    I've been modifying the vi attached today to add the ability to manage several different Enum U16.

    Previously, it there was only a single typedefed enum U16 in controls [] controls entry and the typedef Enum constant was so in the case of U16 Enum.

    Because there are now 2 different typedefed Enum U16 in a new control that is passed in the [input controls, I had to change the vi as Variant data function was causing an error when the variant does not correspond with any one of the types. To do this, I added the new deal structure and wired the exit TypedeInfo of the fuction Type Variant via a Unbundel by name to the case switch terminal. Inside of each case, I put a constant of the Typedef Enum, which must be transmitted to the data vi Variant. Unfortunately as one of the Enum constants are not of the same type, the tunnel exit of the new structure of matter is cohursts so that the data on the screen of the Enum Digtal and not the name of the element.

    This therfore means that the output of the variant of the data function now returns the digital display number and not the name of the element. Unfortunately this messing things downstream.

    He he not cohurst and the collar of the element names instead of the digital display. I guess it would be possible to do with a funtion Selector, but then it does not changes possible futher.

    All ideas

    Concerning

    M

    If you use "format string" or "type cast" with an enum, it converts it into a string that you can wire in the selector box structure. Because your type definitions are different, you will always get the coercion.

    Your VI, you need to move the variant to the data inside the structure of the case and then put inside the case of the Enum U16. Something like this should work:

    Oh, there's also an OpenG function called "Get Strings of Enum" that returns the enum value currently selected and all the strings of the enum.

  • I need a script to count all the text boxes on a form

    I created our organizational structure in Livecycle Designer.  (It doesn't "do" anything, it is just a flat document without subforms, checkboxes, etc.).

    Name of the employee is in a text box.  The text boxes are all named in the same way, starting with the word 'Employee' followed by the name of the employee.  For example, "EmployeeJohnDoe" "EmployeeJaneSmith" etc.

    I need to keep a number of our existing employees and so I need a script that is taken into account in all areas of text named "EmployeeXX".  The answer may go into a text field.

    Thanks in advance!

    Yes,

    The missing point was my bad.

    What do you mean text boxes? If you are referring to text (as opposed to the TextField objects) objects, then you would test against a class name 'draw' and a name "employee".

    Niall

  • How to use the instruction box in where clause

    Hi all


    I need to use cases where clause guide me please how I can do it.


    AND WHEN BOX: KAPCO = "KAPCO" THEN cla. CLASS_NAME LIKE '% KAPCO % '.
    WHEN: KAPCO = "NON_KAPCO" THEN SUPERIOR (cla. CLASS_NAME) NOT LIKE '% KAPCO % '.
    WHEN: KAPCO = 'ALL' GOLD: KAPCO IS NULL SO SUPERIOR (cla. CLASS_NAME) LIKE '% '.
    END



    Concerning

    Published by: user10941925 on March 4, 2012 22:31

    Hello

    CASE expressions return a single value, for example a VARCHAR2. They do refer to code fragments.

    You usually don't need (or want) an expression BOX in a WHERE clause, or any other condition. I think that you were trying to do the equivalent of:

    AND     (     (:KAPCO = 'KAPCO'          AND cla.CLASS_NAME       LIKE '%KAPCO%')     -- Don't you want UPPER on this line?
         OR     (:KAPCO = 'NON_KAPCO'           AND UPPER(cla.CLASS_NAME) NOT LIKE '%KAPCO%')
         OR     (NVL (:KAPCO, 'ALL') = 'ALL'       AND cla.CLASS_NAME IS NOT NULL)
         )
    

    If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.

  • error in the instruction box

    How to select something in a statement in pl/sql block box in a variable plsql?

    It returns the error ORA-00903 invalid tablename.

    I have to use sql to perform this validation

    Why? In your first post you talked about"a pl/sql block '?

    In any case - performs the following work for you:

    SQL> declare
      d1        date := sysdate;
      d2        date := sysdate;
      d3        date := sysdate;
      d4        date := sysdate;
      myvavar   varchar2 (1);
    begin
      select case
               when extract (year from d1) != 0000
                and d1 < d2
               then
                 'X'
               when (extract (year from d3) != 0000)
                and (d3 > d2)
               then
                 'X'
               when (extract (year from d4) != 0000)
                and (d2 < d3)
               then
                 'X'
               else
                 'y'
             end
        into myvavar
        from dual;
    
      dbms_output.put_line (myvavar);
    end;
    /
    y
    PL/SQL procedure successfully completed.
    

    ?

  • using the function min() inside the instruction box

    I have a problem with the following select statement

    Select
    patient_id
    , sum (case when ch.cancer_site_id in ('3', ' 39 ', ' 12') and min (ch.diagnosis_age) < 40 0' then '1' other ' end) in breast cancer
    Of...
    Patient_id group

    I get an error "not a single group group function.


    The main table, that I work with is so implemented.

    PatientID | diagnosis_age | cancer_site_id

    12345678 | 35. 4
    12345678 | 40. 4
    12345678 | 42. 12
    12345678 | 34. 31
    87654321 | 50. 12

    cancer_site_ids 4 and 31 must get grouped together and called breast cancer. cancer_site_id 12 (and others) is cancer of the colon.

    Finally I need the output to look like this

    PatientID | min (breast_diagnosis_age) < 40 | min (breast_diagnosis_age) > 40 | min (colon_diagnosis_age) > 40
    -------------------------------------------------------------------------------
    12345678 | 1. 0 | 1
    87654321 | 0 | 0 | 1

    My final request is much more complicated than that, but it's the last part that I can't understand.

    Hello

    Welcome to the forum!

    You can use the analytic MIN function to get the earlier diagnosis_age.
    Analytical functions are calculated after aggregation functions. If you use the aggregate functions to rotate the data, this means that you need to calculate the minimum age in a subquery and do all aggregates in the main query.
    I mean, it is something like this:

    WITH     got_min_diagnosis_age     AS
    (
         SELECT     patiendid
         ,     MIN (diagnosis_age) OVER ( PARTITION BY CASE
                                            WHEN  cancer_site  IN (4, 31)
                                            THEN  'breast'
                                                WHEN  cancer_site  IN (3, 12, 39)
                                            THEN  'colon'
                                                       END
                              )     AS diagnosis_age
         ,     CASE
                  WHEN  cancer_site  IN (4, 31)     THEN  'breast'
                  WHEN  cancer_site  IN (3, 12, 39)     THEN  'colon'
              END     AS type
         FROM    table_x
    )
    SELECT       patientid
    ,       COUNT ( CASE
                   WHEN  type = 'breast'
                   AND   min_diagnosis_age <= 40
                   THEN  1
                  END
                )     AS breast_up_to_40_cnt
    ,       COUNT ( CASE
                   WHEN  type = 'breast'
                   AND   min_diagnosis_age >  40
                   THEN  1
                  END
                )     AS breast_over_40_cnt
    ,       COUNT ( CASE
                   WHEN  type = 'colon'
                   AND   min_diagnosis_age >  40
                   THEN  1
                  END
                )     AS colon_over_40_cnt
    FROM      got_min_diagnosis_age
    GROUP BY  patientid
    ORDER BY  patientid
    ;
    

    You can also calculate type in a subquery, then use it to calculate the min_diagnosis_age for the type in a second subquery. If the expression to get type is much more complicated in reality that it is in this small sample, which can be better.

    Published by: Frank Kulash, November 3, 2010 15:00

    You have a cancer_site table, that is, a table that has one line for each valid value of cancer_site (3, 4, 12,...)?
    If so, you need to add a column to this table to indicate what kind of cancer, each site is associated. You could join this table in the subquery, rather than using CASE expressions. The fact that 4 of the site is associated with breast cancer is the type of information that belongs to a table, not hardcoded in a query.
    If you do not have a cancer_siote table, thus creating one can be a good idea.

  • If the instruction boxes

    Hi - I have a form that contains a table and inside the table is a column with boxes in it for the contractor to choose whether it's a "subcontractor to the subcontractor," a column description, then a column Original amount of $ and Final amount column paid $.  At the bottom of the page, it adds up to the $ initial amount and the Final amount.  I need to put a javascript in there so that if a contractor clicks on the checkbox for the subcontractor to subcontractor, the amount that they put in the column Original amount of $ and the Final amount column paid $ not added in the totals for these two columns.  Does anyone know how to write a script for this?

    Thank you

    Connie

    Hi Connie,

    Here is the form to the you: https://acrobat.com/#d= * XozdxKbYnmCkRiE4iGWBQ.

    It have the JavaScript code following in the calculate of the total fields event:

    // set up a variable
    var vTotal = 0;
    // resolve the row objects in the table xfa.resolveNode("Row1[0].WorkPerformed")
    var nSub = OriginalAmountTotal.resolveNodes("Row1[*].SubtoSubCheckbox");
    var nAmount = OriginalAmountTotal.resolveNodes("Row1[*].num_FinalAmountPaid");
    
    // set up a loop to go through the repeating rows
    for (var i=0; i
    

    Hope that helps,

    Niall

  • Missing keyword in the instruction box

    Hello

    I get a keyword missing in my case statement that I wondered if I could pick up your brain.

    case when IDENTITY_CODE = 9777
     then
     case when bas1_gl_adj_id='STD UNREALIZED GAIN /LOSS RECLASS-REVERSAL' or bas1_gl_adj_id like 'Offset%' then 2
          when bas1_gl_adj_id='STD UNREALIZED GAIN/LOSS RECLASS-ADD BACK' then 3 else 1 end as REC_NO
     else
     case when bas1_gl_adj_id='IP UNREALIZED GAIN RECLASS-REVERSAL' or bas1_gl_adj_id like 'Offset%' then 2
          when bas1_gl_adj_id='IP UNREALIZED GAIN RECLASS-ADD BACK' then 3 else 1 end as REC_NO,
    
    

    See below the strike through you have not need it as you miss END below

    -case when IDENTITY_CODE = 9777

    then

    -case when bas1_gl_adj_id = "GAIN /LOSS not MATERIALISE STD RECLASS-INVERSION" or bas1_gl_adj_id as 'Offset %' then 2

    When bas1_gl_adj_id = 'RECLASS-ADD of STD GAIN/LOSS on CASH BACK' then 3 end otherwise 1 - as REC_NO

    on the other

    -case when bas1_gl_adj_id = "IP GAIN not MATERIALISE RECLASS-INVERSION" or bas1_gl_adj_id as 'Offset %' then 2

    When bas1_gl_adj_id = 'IP GAIN not MATERIALIZED RECLASS - ADD BACK' then 3 or 1 end

    END-> you miss it

    as REC_NO

  • DEFAULT CONSTRAINT with the INSTRUCTION BOX - Oracle 11.2.0.3

    Is it possible to create a default constraint on a table based on conditional logic.

    For example:

    CREATE TABLE TEST_T (NUMBER OF DEPT_NO,

    GRANT_FL CHAR (1)

    );

    GRANT_FL DEPT_NO

    10             Y

    10             Y

    0               N

    I want the DEPT_NO to be filled with a default value of 10 only when GRANT_FL = 'Y' otherwise the value to 0.

    I can do that with an after Insert trigger, but would be better if this can be done via the case statement that sets a default value.

    Thank you very much!

    Kevin

    Hi, Kevin,

    Sorry, I don't think that there is a way to do it with the DEFAULT options.

    Kevin_K wrote:

    ... I can do this with an after Insert trigger...

    I think that a trigger is your best bet, but a BEFORE INSERT trigger would be much simpler and more effective?  An INSTEAD OF trigger is another possibility.

  • update with the instruction box

    Hello

    I need to do something like this:

    update my_table set (prelucrat, err) = (select case
                                                             when r.id is not null then
                                                               ('D', null)
                                                             else
                                                               ('N', 'Nu exista persoana cu marca '||r.marca)
                                                           )
    where marca = r.marca and ctiserver = r.ctiserver
    

    But I got an error 'missing right parenthesis.

    'r' is a cursor variable, so this update is nested in one 'for r in (...) ". loop. "

    What I am doing wrong? Is it possible to update both the two columns, then select in this use case?

    Thank you.

    for r in loop (select...)

    Update my_table

    Set prelucrat = nvl2(r.id,'D','N')

    , err = nvl2 (r.id, null, 'Nu exista person cu marca' | r.marca)

    where marca = r.marca

    and ctiserver = r.ctiserver;

    end loop;

    ----

    Ramin Hashimzade

  • Calculation of measurement using the division and the instruction box

    Hello Experts

    I have a measure that calculates the percent of sales by State - "sale by States" / "Total sales" * 100 and the requirement is when the numerator of the measure is < 11 then it should be set to 0. I tried to write a next case statement case when sales by State < 11 THEN 0 ELSE sales by State / "Total sales" * 100. I get an error of syntax ideas how I can make it work.

    Thank you
    RC

    RC,

    It is always useful in the forum when you post your code and the associated error. Of what you provided; It seems that your case statement is missing from the end clause and it should look like this:

    SELECT CASE
              WHEN sales_per_state < 11 THEN 0
              ELSE sales_per_state / "Total Sales" * 100
           END
      FROM your_table
    

    Jeff

  • A subquery within the instruction BOX

    I try to use a subquery in a Case statement with a condition 'where' that binds at the request of the mother. Like this:
    Select T.idperson , CASE WHEN  T.type = 'C' THEN (SELECT name from Customers where C.idcustomer = T.idperson) 
    ELSE
     (SELECT name from Providers where idprovider = T.idperson)
     END Name 
    from myTable T 
    It works for me in SQL Server, but in ORACLE the subquery does not return line, I guess that it is binding to the parent query part. All thoughts in another way, I could get the result I want?

    Thank you

    JuanDiego

    Hi, Juandiego,

    If it's not returns all rows, you must have all the lines in the table.
    If you have lines in the table, you either get
    (a) an error or
    (b) some lines (even if the columns are set to NULL).

    There is another way to get the desired results.
    I probably wouldn't use scalar subqueries. I'd do it outer join all the tables, like this:

    Select  T.idperson
    ,       CASE
                WHEN  T.type = 'C'
                THEN  c.name
                ELSE  p.name
            END  AS Name
    from             myTable   t
    LEFT OUTER JOIN  Customers c  ON c.idcustomer = T.idperson
    LEFT OUTER JOIN  Providers p  ON p.idprovider = T.idperson
    ;
    

Maybe you are looking for

  • Pairing Bluetooth headset with Apple Watch 2 series?

    Hoping that someone here has some good ideas, so I can avoid having to go through the centre commercial/Apple Store! Bought a watch series 2 the day of the launch, immediately tried to pair with the bluetooth headphoens I got (AvierBTE somethings). N

  • Why can not my clients or I discovered my own site on FireFox?

    Hello everyone, I'm going to share a video with you here on what happens to best explain it. Please watch carefully. https://youtu.be/ryPPctB8iJg For those unable to display, in basic, even with all disabled add-ons, I am still unable to connect or d

  • Questions about the Skype Online numbers

    Is it possible for me to affliate several numbers online with my account? Example, Korea, Japan, United States and Canada so calling them can call and leave me a message to my sales visits? Also, do I need Skype for this business?

  • Portege 3500 - hangs on step 8 during the recovery procedure

    Hello, I've had the laptop less hard drive, I have istalled a HARD drive is appropriate, but the external CD-ROM drive, it is the good, is not recognized. I followed these instructions:http://support.toshiba-tro.de/KB0/TSB6101CA000ER02.htm Everything

  • Cannot delete the playlist "iptv" in the music app

    In the application 'Music' playlist are made automatically and it is called "iptv", I don't know if that occurred after I downloaded a third party application. I erased the music application cache and uninstalled is updated, then updated to the most