Helps the query using case and County

Hello!

I have problems with a small part of a query below that finally can settle the invoice price.

(count (distinct spm97.sample_id) * 36.1) as "PROFILE."
case count (distinct spm33.sample_id)
When (count (distinct spm97.sample_id) = 0) then (count (distinct spm33.sample_id) * 26)
another (count (distinct spm33.sample_id) * 4.75)
put an end to 'CC ',.

The first line works - 0 or 36.10 is returned depending on whether or not a profile has been ordered for the sample.

The cost of CC is 4.75 if a profile was also sentenced, if it isn't then the cost is 26. The case statement is supposed to verify this and return the exact amount, but I can't make it work... I get the error message that a closing parenthesis is missing somewhere in the middle of line 3, if that helps.

Any advice would be much appreciated! Of course, this isn't the entire query - joins and all are all working well, it's just this little section with the County that I can't just.

Thank you

JO

the piece of code below, seems to me is incorrect

    CASE COUNT(DISTINCT spm33.sample_id)
        WHEN
            (
                COUNT(DISTINCT spm97.sample_id) = 0
            )
        THEN (COUNT(DISTINCT spm33.sample_id) * 26)
        ELSE (COUNT(DISTINCT spm33.sample_id) * 4.75)
    END AS "CC"

It seems that the requirement here is that if * 'COUNT (DISTINCT spm97.sample_id) = 0' *, then * "CC" * should be ' COUNT (DISTINCT spm33.sample_id) (* 26) "ELSE, it should be" COUNT (DISTINCT spm33.sample_id) (* 4.75)»
If this is the case, the statement must include:

    CASE COUNT(DISTINCT spm97.sample_id)
        WHEN
            0
        THEN (COUNT(DISTINCT spm33.sample_id) * 26)
        ELSE (COUNT(DISTINCT spm33.sample_id) * 4.75)
    END AS "CC"

Tags: Database

Similar Questions

  • Helps the query using LESS

    Hello Experts

    I can't in select the record_sequence in the output. Please see the part of the desired effect.
    Please help solve this problem.

    Is the version of Oracle, I'm working on that

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options

    Thank you

    RB

    TABLE1 AS
    (
    SELECT '28' EXAM_CD1, EXAM_CD2 '29', '10' EXAM_CD3, 111' CAND_ID FROM DUAL UNION ALL
    SELECT '21' EXAM_CD1, EXAM_CD2 '39', '20' EXAM_CD3, 112' CAND_ID FROM DUAL UNION ALL
    SELECT '22' EXAM_CD1, EXAM_CD2 '49', '30' EXAM_CD3, 113' CAND_ID FROM DUAL UNION ALL
    SELECT 'EXAM_CD1 23', '59' EXAM_CD2, EXAM_CD3 ' 40', 114' CAND_ID FROM DUAL UNION ALL
    SELECT '24' EXAM_CD1, EXAM_CD2 '69', '50' EXAM_CD3, 115' DOUBLE CAND_ID)
    AS TABLE2
    (
    SELECT EXAM_CD '28', '111' CANDID, 1 RECORD_SEQ OF DOUBLE UNION ALL
    SELECT '30' EXAM_CD, '113' CANDID, 2 RECORD_SEQ FROM DUAL UNION ALL
    SELECT EXAM_CD '94', '111' CANDID, 3 RECORD_SEQ OF DOUBLE UNION ALL
    SELECT EXAM_CD '69', '115' CANDID, 4 DOUBLE RECORD_SEQ)
    (
    SELECT EXAM_CD FROM TABLE2, CANDID
    LESS
    SELECT CAND_ID,
    MAX (L CASE WHEN 1 EXAM_CD1 THEN WHEN 2 THEN of OTHER EXAM_CD2 EXAM_CD3 END) exam_code
    FROM TABLE1,
    (SELECT LEVEL L FROM DUAL CONNECT BY LEVEL < = 3)
    CAND_ID GROUP, L)

    The aim is

    CAND_ID, EXAM_CD, RECORD_SEQ
    * 111, 94, 3 *.

    Hello

    Rb2000rb65 wrote:
    The solution use not less as long as I get my results using the latest features, it is good with me.

    Good idea!
    UNMIS is not the best tool for this task. The saved query gets the exam_cd and the Candide you want, but you can't find the record_seq because there of nothing like record_seq in table1.

    You can do this way:

    SELECT     *
    FROM     table2     m
    WHERE     NOT EXISTS (
                        SELECT  1
                    FROM    table1
                    WHERE   m.candid      = candid
                    AND     m.exam_cd  IN ( exam_cd1
                                             , exam_cd2
                                 , exam_cd3
                                 )
                 )
    ;
    

    I guess you could use LESS, like this

    SELECT     *
    FROM     table2
    WHERE     (exam_cd, candid)
         IN (
                SELECT  ...  -- The MINUS query you posted goes here
            )
    ;
    

    but it is unecessarily complicated.

  • Helps the query using summary on partition

    I don't know that miss me something small here. I need to make an inventory of end.
    The formula is the following:


    For the 501, end = store inventory
    -closing inventory 7292.19
    -supplies - 30,64 closing stock
    -closing inventory for buns - 1002.34
    = -----------
    6259.21
    I can get the stock of closing with analytics, but cannot end inventory.

    My dollar gap is also swollen. It should be 780.55 for store 501;

            
      CREATE TABLE "SUBQUERY_CATEGORIES" 
       (     "STOREID" NUMBER NOT NULL ENABLE, 
         "WEEK_NBR" NUMBER, 
         "DESCRIPTION" VARCHAR2(100 BYTE) NOT NULL ENABLE, 
         "OPEN_INVENTORY" NUMBER, 
         "CLOSING_INVENTORY" NUMBER, 
         "TRANSFER_IN_COST" NUMBER, 
         "TRANSFER_OUT_COST" NUMBER, 
         "DELV_COST" NUMBER, 
         "PREV_DELV_COST" NUMBER, 
         "TOTAL_COST" NUMBER, 
         "DOLLAR_VARIANCE" NUMBER
       ) ;
     
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Other Foods-I',880.04,837.16,17.32,0,491.92,880.044,837.158,35124.92);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Shortening-I',199.7,200.32,0,0,99.85,199.7,200.324,390.45);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Meat-I',154.69,464.06,168.75,42.188,1406.25,154.688,464.063,1239.85);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Bacon-I',74.99,62.63,19.405,0,154.16,74.992,62.628,1239.85);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Repairs & Maint',0,0,0,0,195,0,0,780.55);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Supplies',25.92,30.64,0,0,139.43,25.923,30.637,37466.58);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Drinks-I',585.06,750.36,0,0,715.87,585.058,750.358,8678.93);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Chili Ingridients-I',177.99,214.47,5.918,5.918,302.88,177.995,214.466,4683.32);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Meat-I',540,264.38,14.063,28.125,1181.25,540,264.375,780.89);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Paper-I',955.71,839.86,0,15.308,600.54,955.71,839.859,19131.9);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Supplies',11.78,9.43,0,0,158.85,11.783,9.427,17570.11);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Produce-I',180.5,98.64,0,0,206,180.498,98.638,3904.47);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Condiments-I',170.14,153.46,8.668,0,164.86,170.14,153.456,6819.16);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Repairs & Maint',0,0,0,0,500,0,0,390.45);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Fries-I',78.22,120.33,54.15,18.05,631.75,78.217,120.333,619.92);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Paper-I',1113.09,1093.63,50.884,14.07,846.22,1113.089,1093.633,43711.01);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Cheese-I',63.78,58.7,0,0,197.07,63.783,58.704,1171.34);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Produce-I',201.56,304.85,0,0,554.85,201.56,304.847,7805.54);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Buns-I',1064.44,793.73,0,0,191.36,1064.44,793.73,780.89);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Bacon-I',251.95,155.9,0,0,115.62,251.95,155.902,780.89);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Paper-I',806.87,871.74,12.113,8.448,674.56,806.871,871.741,30376.25);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Chicken-I',561.16,570.93,94.457,0,1568.81,561.156,570.929,5463.88);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Chicken-I',285.86,534.67,73.007,35.97,1402.86,285.858,534.67,4339.46);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Drinks-I',1061.6,1040.97,0,0,584.59,1061.597,1040.971,5466.26);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Breakfast-I',437.9,376.44,0,0,272.42,437.904,376.438,12488.86);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Condiments-I',173.67,159.72,0,3.251,187.55,173.671,159.721,4294.92);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Chili Ingridients-I',93.59,149.49,2.445,0,253.85,93.594,149.489,3719.54);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Buns-I',873.54,914.48,0,0,441.6,873.54,914.48,1239.85);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Fries-I',39.11,126.35,36.1,36.1,884.45,39.108,126.35,780.55);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Supplies',4.71,4.71,0,0,195.53,4.713,4.713,27896.56);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Other Foods-I',615.63,627.42,1.701,0,374.4,615.63,627.419,26656.71);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Chicken-I',702.5,471.66,0,65.64,1120.39,702.502,471.664,2733.13);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Dairy-I',176.9,128.3,0,0,332.14,176.904,128.304,5463.88);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Dairy-I',171.78,85.3,0,0,109.38,171.783,85.297,2342.68);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Dairy-I',122.71,89.86,0,0,288.98,122.706,89.856,3719.54);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Cheese-I',140.03,109.46,0,0,131.38,140.028,109.461,1859.77);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Produce-I',151.15,169.85,0,3.44,270.85,151.148,169.852,6199.23);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Shortening-I',249.63,259.61,0,0,259.61,249.625,259.61,780.55);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Bacon-I',116.58,115.62,0,0,308.32,116.581,115.62,1561.11);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Repairs & Maint',0,0,0,0,200,0,0,619.92);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Cheese-I',130.9,174.52,0,0,328.45,130.897,174.516,2341.66);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Condiments-I',225.65,207.39,0,0,247.81,225.645,207.394,8586.09);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Chili Ingridients-I',159.45,109.79,5.918,0,159.6,159.45,109.788,2342.68);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Meat-I',752.34,696.09,0,28.125,1800,752.344,696.094,1561.11);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Buns-I',1090.2,1002.34,0,0,524.4,1090.2,1002.34,1561.11);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Fries-I',147.41,88.75,0,0,595.65,147.408,88.746,390.45);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (27,1,'Other Foods-I',658.37,645.92,0,1.701,373.34,658.375,645.925,16789.22);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (501,1,'Drinks-I',1290.03,1153.85,0,0,689.84,1290.032,1153.848,12488.86);
    Insert into SUBQUERY_CATEGORIES (STOREID,WEEK_NBR,DESCRIPTION,OPEN_INVENTORY,CLOSING_INVENTORY,TRANSFER_IN_COST,TRANSFER_OUT_COST,DELV_COST,PREV_DELV_COST,TOTAL_COST,DOLLAR_VARIANCE) values (25,1,'Shortening-I',159.76,179.73,0,0,199.7,159.76,179.73,619.92);
    
    SET DEFINE OFF 
    
    with categorycosts as 
     ( 
             SELECT             storeid 
                                 ,  week_nbr
                                 ,  UPPER(TRIM(description))  description                
                                 ,  NVL(prev_delv_cost + transfer_in_cost + delv_cost - transfer_out_cost - total_cost, 0) AS  cost 
                                 ,  open_inventory 
                                 ,  dollar_variance                         
                                 ,  sum(closing_inventory ) over (partition by storeid, week_nbr )  closing_inventory                   
                           --    ,  closing_inventory
                              from  subquery_categories
                              where storeid = 501
     )
      ,  pivoted_cat_costs AS
     (SELECT  storeid
                 , week_nbr
                , MAX(DECODE(closing_inventory, 0, 0, closing_inventory))  -  NVL(MAX(DECODE(UPPER(TRIM(description)), 'SUPPLIES', cost)), 0)  -       NVL(MAX(DECODE(UPPER(TRIM(description)), 'BUNS-I', cost)), 0)      as   closing_inventory
                , MAX(DECODE(dollar_variance, 0, 0, dollar_variance))                as   dollar_variance
               ,    NVL(MAX(DECODE(UPPER(TRIM(description)), 'SUPPLIES', cost)), 0)                 supplies
               ,    NVL(MAX(DECODE(UPPER(TRIM(description)), 'REPAIRS & MAINT', cost)), 0)                     repairs_and_maint        
               ,    NVL(MAX(DECODE(UPPER(TRIM(description)), 'BUNS-I', cost)), 0)             as buns            
          FROM   categorycosts
          GROUP BY storeid,  week_nbr
     )
    select * from pivoted_cat_costs;
    -= = So I separated it and still get incorrect result
          SELECT                   storeid   
                                 ,  week_nbr
                                 ,  UPPER(TRIM(description))  description                
                                 ,  NVL(prev_delv_cost + transfer_in_cost + delv_cost - transfer_out_cost - total_cost, 0) AS  cost 
                                 ,     open_inventory 
                                 ,    dollar_variance                         
                             --  ,   sum(closing_inventory ) over (partition by storeid, week_nbr )  closing_inventory                   
                                 ,             closing_inventory
                              from  subquery_categories;
     
    The results should be:
     store 501                   ending inventory  =  6259.21            buns s/b   1002.34                inv variance 780.55
     Store 27                    ending inventory  =  4220                 buns s/b = 793.73                inv variance 390.45 
     Store 25                    ending inventory  =  4283                 buns       914.48                  inv variance 619.92
    There is an anomaly out Bill so it can produce the vairiance of good quality, but inv variance that my request is back is swollen.
    Can someone tell me what I am doing wrong?

    Published by: TheHTMLDJ on December 9, 2009 06:42
    SET DEFINE OFF has added and removed the subquery_categories schema name

    Well, I asked for the logic as the specification and not necessarily a query. :)
    Here's the query that gets your inventory of desired end.

    with categorycosts as
     (
             SELECT             storeid
                                 ,  week_nbr
                                 ,  UPPER(TRIM(description))  description
                                 ,  NVL(prev_delv_cost + transfer_in_cost + delv_cost - transfer_out_cost - total_cost, 0) AS  cost
                                 ,  open_inventory
                                 ,  dollar_variance
                                 ,  sum(closing_inventory ) over (partition by storeid, week_nbr )  closing_inventory
                                 ,  DECODE(UPPER(TRIM(description)), 'SUPPLIES', closing_inventory) supp_cls_inv
                                 ,  DECODE(UPPER(TRIM(description)), 'BUNS-I', closing_inventory) bun_cls_inv
                              from  subquery_categories
                              where storeid = 501
     )
      ,  pivoted_cat_costs AS
     (SELECT  storeid
                 , week_nbr
                , MAX(DECODE(closing_inventory, 0, 0, closing_inventory))  -  NVL(MAX(supp_cls_inv), 0)  -       NVL(MAX(bun_cls_inv), 0)      as   closing_inventory
                , MAX(DECODE(dollar_variance, 0, 0, dollar_variance))                as   dollar_variance
               ,    NVL(MAX(DECODE(UPPER(TRIM(description)), 'SUPPLIES', cost)), 0)                 supplies
               ,    NVL(MAX(DECODE(UPPER(TRIM(description)), 'REPAIRS & MAINT', cost)), 0)                     repairs_and_maint
               ,    NVL(MAX(DECODE(UPPER(TRIM(description)), 'BUNS-I', cost)), 0)             as buns
          FROM   categorycosts
          GROUP BY storeid,  week_nbr
     )
    select * from pivoted_cat_costs;
    

    I still don't know the logic (or specifications) to derive your dollor expected variance.

  • How to insert image from mysql into the table using php and create the checkbox in the table?

    How can I insert image from mysql into the table using php and create the checkbox for each data as a vote? Here is my code...

    WELCOME

    connect_error) {die ("connection failed:".)} $conn-> connect_error); } $sql = "SELECT no, Calon, ID, of course, the Image OF THE candidates." $result = $conn-> Query; If ($resultat-> num_rows > 0) {echo ' '; export data of each line while ($row = $result-> fetch_assoc()) {"echo"}}
    NO Candidate INFO Vote
    " . $row ["no"]. "-" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ['class']. "
    "; } ECHO ' ' ;} else {echo '0 results' ;} $conn-> close();?} >

    hope someone can help me because I am a newbie in this program... need to finish this project... Thank you.

    If you have saved the file name in the database, it's pretty simple.

    echo '' . $row['description'] . '';
    

    Is the same for the box:

    echo '';
    

    If you have saved the image file in the database, it is much more complicated. I recommend you store only the file name in the database.

  • IPhone 7, there will be an adapter jack allowing the two using headphones AND charger?

    IPhone 7, there will be an adapter jack allowing the two using headphones AND charger?

    Hello

    Apple has not yet announced a.

    You can submit your comments and suggestions to Apple here:

    https://www.Apple.com/feedback/iPhone.html

  • the tag of 'mode' in the editable using getconfig() and setconfig() vhost.xml file?

    the tag of 'mode' in the editable using getconfig() and setconfig() vhost.xml file?

    Use the same code I gave before, simply replace:

    admin_nc. Call ("setConfig2", new Result1 (), "Proxy/Mode", "remote", "Adaptor:_defaultRoot_ / VHost:_defaultVHost_");

    by

    admin_nc. Call ("getConfig2", new Result1 (), "Proxy/Mode", "Adaptor:_defaultRoot_ / VHost:_defaultVHost_");

    Redefine Result1() as:

    function Result1() {}

    this.onResult = {function (info)}

    If (info.code == "NetConnection.Call.Success") {}

    for {(i in info.data)

    trace (info. Data [i]);

    }

    }

    }

    }

  • I hear a lot about several programs for maximum protection, how can I use the firewall of cases AND stop the rest of loading or starting at startup?

    At the start of my acer aspire desktop from walmart (not saying not just because his Wal-Mart like this cant be) I noticed that mcafee takes up some space, whenever she starts up. I only need the firewall and what is needed to run just the firewall. I use panda antivirus for viruses and malwarebytes antimalware for this. I would like to know, step by step if possible... How to stop or 'block' additional cases of services from the very beginning that it interferes with the pandas scanner, spikes in CPU when I don't need to use it and occationally crashes my computer by overloading, my ram is 500 MB and it started happening a few days out of the box. Once I have shut down the computer runs faster, but I lose my firewall, so I don't really wish to go unprotected, but really not need the rest services case as I hav more to compensate. The only thing I want to know here's how to get to where I can block all mcafee services that do not affect its ' firewall service while preventing others from starting in the first place. I don't mean that I found through research on the internet because they do not explain how it's done and avoid mentioning insofar as I've seen. If the answers there, I give credit to those who has asked and answered before, I just need help. :'(c'est un windows 8.1 je crois, mais si cela semble éteint juste me dire où regarder vers le haut, de toute façon je doute qui aura une incidence sur ma question trop.)

    I don't know if this is possible. If it was me, I remove McAfee completely and just use Windows Firewall. It is the only firewall I have used for ten years and never had any problems.
     
    How to uninstall or reinstall supported McAfee products using the McAfee Consumer Products Removal tool
    http://service.McAfee.com/FAQDocument.aspx?ID=TS101331
     
     
  • Helps the query in the effects control.

    Hello everyone, I hope that someone can help you.

    I have a little trouble trying to move images around the screen in my sequence to create an animation of a cursor moving to another location. The problem is when I put a marker in the query in the effect control to it's own journey sometimes going upward or down or left or right. I see that there are lines that are the focus of the image, as well as those of the tool pen in Photoshop and I think that that is what is causing the image of the cursor moving on its own. The two same lines by an image to make a smooth arch of movement these lines of travel to smooth the movement rather than a simple at the following location.

    I was wandering because this is the case whenever I put a new marker in the motion effects controls if there is something that is originally what I can disable. I can move these lines from the central point, but that does not make the smoother actions in my sequence.

    Any help is really appreciated.

    You set keyframes on linear:

    Adobe Premiere Pro help. Control to make changes using keyframe interpolation

  • How to display dynamic menu with the parent and the child using c# and sql server

    Hello

    Can you tell me

    What is menu given Dynamics example

    How can u use my dynamic menu added project in c#

    This menu is display with only the data from sql database.

    Menu with the help of a parent node and a child.

    check the element all in sql server and adding one by a dynamic menu.

    Hello

    Thank you for writing to Microsoft Communities.

    I recommend you post your query in the following forum.

    http://social.msdn.Microsoft.com/forums/en/category/SQLServer/

    Hope this information is useful.

  • change / stop the query using bad plan

    I use 11.2.0.3.  I'm wrong a script with multiple insert into... Select.  One of the insert running for hours because it is using bad plan because of State statistics.   I've now updated the statistics. Is - it there anyway I can do oracle raise this insert or ignore this insert and continue with the other inserts in my script. (I don't want to kill the session, I want to run other sqls).

    Also, for the future is there a way to make oracle dynamic sampling rather than obsolete statistics usage?

    I was able to cancel the query in another session to help

    execDBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS (sid, serial#, 'CANCEL_SQL');

  • 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

  • Update the query using nulls update box

    I need to update a column according to the conditions that I've used below, the update query, I used is updated as well to null values. How can I stop this and keep the old values when no match was found for the case.
    create table sample (name varchar2(10),eno number(10),salary number(10));
    insert into sample (name,eno,salary) values ('emp1',1,100);
    insert into sample (name,eno,salary) values ('emp2',2,200);
    insert into sample (name,eno,salary) values ('emp3',3,300);
    select * from sample;
        
    update sample 
    set salary = 
    case when salary = 100 then 10000 else 
    case when salary = 150 then 15000 else 
    case when salary = 200 then 20000 end end end
    where name is not null;
           
    Actual o/p:
           emp1     1     10000
           emp2     2     20000
           emp3     3     
    
    Required o/p:
            emp1     1     10000
           emp2     2     20000
           emp3     3      300

    Hello

    The updated control WHERE clause lines.
    If you do not have a WHERE clause, then updates all rows in the table.

    update  sample
    set      salary = case
                          when salary = 100 then 10000
                   when salary = 150 then 15000
                   when salary = 200 then 20000
               end
    where   salary   IN (100, 150, 200)
    ;
    

    Note that you do not need to nest BOX icies expressions (or almost anywhere else). If the 'salary = 100' condition is true, then its correspondent WHEN the value is returned, and the remaining terms will not be evaluated. If the first condition is not true, then only will be the "salary = 150" condition to be evaluated. (The terms are mutually exclusive in this example anyway, so it does not matter.)

    Published by: Frank Kulash, June 5, 2012 13:09

  • Report with the query with union and parameters

    Hello

    We have an obligation to create a report with the request, which is the union and parameters.

    I intend to create a database for the report based on a query. But the problem here is that the way to pass parameters in the query.

    Request is something like that

    Select x.a, x.b, x.c
    x
    where x.year =: para1
    and x.status = 'A '.
    Union of all the
    Select x.a, x.b, x.c
    x
    where x.year =: para1 - 1
    and (x.status = 'c' and x.date =: para2 or x.status = 'I' and x.date < =: para2)

    Here x.year in the first select statement must be equal to: para1 and second select statement, it should be: para - 1.

    How this requirement can be achieved?

    Client don't want to separate worksheet, a parameter and another for the actual data that I tried with sys_context and it worked. But the client wants the result in a single sheet only... So I need to change their approach.

    Help, please.

    Thank you

    Hello
    Another option is to convert the request so that you will have the items from the selection
    for example on the query you provided that you can use:

    Select 'Curr' rec_type, x.a, x.b, x.c, x.year, x.date, x.status
    x
    where x.status = "A".
    Union of all the
    Select 'Prev' rec_type, x.a, x.b, x.c, x.year, x.date, x.status
    x
    where x.status in ('c', 'I')

    then, in the workbook, you will be able to create conditions such as:
    rec_type = 'Curr' and year =: para1

    rec_type = 'Prev' and year =: para1-1
    rec_type = 'Prev' and (status = 'c' and date =: para2 or status = 'I' and date)<=>

    Tamir

  • Satellite L300D-10U - unable to connect to the internet using LAN and Win XP

    Hi all

    I had a very big problem with my card.
    I can t connect to the internet.
    I searched the forum but without any determination :(

    I did everything. I have checked ipconfig nothing, check the mode safe mode with local network nothing.
    Someone said too
    "(1) once the Ethernet is connected, power of the DSL Modem. Cycle." ("Some Modem picks up the MAC ADDRESS of the network card on where it was previously connected and restarting it redétecte this new")

    How to disable the modem?
    And another question: can someone tell me what works of LAN drivers in Sat L300D-10U on XP?
    I put t even know that :(

    Help me

    Hello

    The Satellite L300D-10U belongs to the series of PSLC0E and it supports the Realtek LAN card.
    LAN driver can be found on the page of Realtek.

    You ask how to disable the modem? I think you mean how to reset modem DSL
    Well, usually your modem should support an ON / OFF button simply turn it off and then turn it back on.

    If you are unable to access the internet then you should first check if your modem is properly configured and that the right data ISP (internet service provider) was used.

    Sorry, but that's all I can say right now I think you should just check your modem settings, make sure that the NIC is properly recognized and connect the model of the laptop using a LAN cable.

    All that s

  • explain the plan using plan_hash_value and runtime

    Hello

    Please let me know the syntax to get the plan to explain using sql_id and plan_hash_value.

    Also let me know how to find out the same sql execution times in the previous months. I have the ID value of sql.

    Kind regards

    VN

    > Is it possible to check how long the sql finished in the previous months?

    Of AWR / StatsPack reports.

    Or use awrsqrpt.sql which can query the repository for a single SQL_ID AWR.

    However, you must have the AWR data kept for 4 months.  The default retention is 7 days.

    Hemant K Collette

Maybe you are looking for