[8i] Best way to replace "similar" values with one value...?

Below is some sample data:
Sorry for the large set / complex set of sample data, but there should be no need to go through it in detail =).
2 things to keep in mind:
1) This is an 8i db
2) I cannot create any new tables within this db, though I can create views
CREATE TABLE     ord_master
(     part_nbr          CHAR(25)
,     ord_nbr          CHAR(10)
,     sub_ord_nbr     CHAR(3)
,     ord_type          CHAR(2)
,     ord_stat          CHAR(2)
,     date_closed     DATE
-- please note, though none of the columns in ord_master are explicitly defined as NOT NULL,
-- none of them are NULL in the db, and given how things are input into the table, I don't
-- even think it's possible
-- a unique order is described by ord_nbr, sub_ord_nbr.  there should only be one record in
-- this table for a given unique combination of those columns, though they are not the p.k.
-- NOTE: dates default to 12/31/1900, so in the table above, if an order is still open (thus,
-- not closed), it's date_closed will be 12/31/1900.  It will only change once the order closes.
INSERT INTO     ord_master
VALUES     ('ABC-123','1','1','AA','CL',TO_DATE('05/01/2009','mm/dd/yyyy'));
INSERT INTO     ord_master
VALUES     ('ABC-123','1','2','AA','CL',TO_DATE('9/14/2009','mm/dd/yyyy'));
INSERT INTO     ord_master
VALUES     ('ABC-123','2','1','AA','CL',TO_DATE('12/03/2009','mm/dd/yyyy'));
INSERT INTO     ord_master
VALUES     ('ABC-123','3','1','AA','OP',TO_DATE('12/31/1900','mm/dd/yyyy'));
INSERT INTO     ord_master
VALUES     ('ABC-123','4','1','AA','CL',TO_DATE('03/12/2004','mm/dd/yyyy'));
INSERT INTO     ord_master
VALUES     ('XYZ-123','5','1','AA','CL',TO_DATE('03/12/2004','mm/dd/yyyy'));
CREATE TABLE     op_detail
(     ord_nbr          CHAR(10)
,     sub_ord_nbr     CHAR(3)
,     major_seq_nbr     CHAR(4)
,     wctr_id          CHAR(5)
,     oper_stat          CHAR(2)
,     plan_su_rsrc     NUMBER(5,2)
,     plan_run_rsrc     NUMBER(11,8)
,     plan_subc_amt     NUMBER(15,5)
,     act_su_rsrc     NUMBER(5,2)
,     act_run_rsrc     NUMBER(7,2)
,     act_subc_amt     NUMBER(15,2)
,     act_start_dt     DATE
,     dt_completed     DATE
,     qty_planned     NUMBER(13,4)
,     qty_recvd          NUMBER(13,4)
,     qty_complete     NUMBER(13,4)
,     qty_scrap          NUMBER(13,4)
,     qty_on_hold     NUMBER(13,4)
-- similar to ord_master, thought none of the columns are explicitly defined as NOT NULL,
-- none of the records have NULL values for any of these columns, and I don't think it's
-- really possible with the way the system is
INSERT INTO     op_detail
VALUES     ('1', '1', '0081', 'X516 ', 'CP', 0, 0, 0, 0, .2, 0, TO_DATE('02/03/2010', 'mm/dd/yyyy'), TO_DATE('02/03/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '1', '0324', 'Y000 ', 'CP', .1, .2, 0, 0, .87, 0, TO_DATE('04/06/2010', 'mm/dd/yyyy'), TO_DATE('04/06/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '1', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 159, TO_DATE('03/05/2010', 'mm/dd/yyyy'), TO_DATE('03/05/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '1', '0130', 'H211 ', 'CP', .5, .1, 0, .08, .63, 0, TO_DATE('02/10/2010', 'mm/dd/yyyy'), TO_DATE('02/10/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '2', '0120', 'H214 ', 'CP', .3, .05, 0, 0, .68, 0, TO_DATE('05/22/2009', 'mm/dd/yyyy'), TO_DATE('05/22/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '2', '0122', 'T203 ', 'CP', 2.5, 1, 0, .67, .3, 0, TO_DATE('05/28/2009', 'mm/dd/yyyy'), TO_DATE('05/28/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '2', '0130', 'H211 ', 'CL', .5, .1, 0, .67, .3, 0, TO_DATE('05/28/2009', 'mm/dd/yyyy'), TO_DATE('05/28/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '2', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 153.12, TO_DATE('06/10/2009', 'mm/dd/yyyy'), TO_DATE('06/10/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('1', '2', '0324', 'Y000 ', 'CP', .1, .2, 0, 0, .08, 0, TO_DATE('06/17/2009', 'mm/dd/yyyy'), TO_DATE('06/17/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
INSERT INTO     op_detail
VALUES     ('2', '1', '0081', 'X516 ', 'CL', 0, 0, 0, 0, 0, 0, TO_DATE('07/20/2009', 'mm/dd/yyyy'), TO_DATE('07/20/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
INSERT INTO     op_detail
VALUES     ('2', '1', '0324', 'Y000 ', 'CL', .1, .2, 0, 0, 3.03, 0, TO_DATE('09/11/2009', 'mm/dd/yyyy'), TO_DATE('09/11/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
INSERT INTO     op_detail
VALUES     ('2', '1', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 204.16, TO_DATE('08/11/2009', 'mm/dd/yyyy'), TO_DATE('08/11/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
INSERT INTO     op_detail
VALUES     ('2', '1', '0130', 'H211 ','CP', .5, .1, 0, 1.97, 2.67, 0, TO_DATE('07/28/2009', 'mm/dd/yyyy'), TO_DATE('07/29/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
INSERT INTO     op_detail
VALUES     ('3', '1', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 255.2, TO_DATE('11/06/2009', 'mm/dd/yyyy'), TO_DATE('11/06/2009', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
INSERT INTO     op_detail
VALUES     ('3', '1', '0130', 'H212 ', 'CP', .5, .1, 0, .6, .03, 0, TO_DATE('10/21/2009', 'mm/dd/yyyy'), TO_DATE('10/21/2009', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
INSERT INTO     op_detail
VALUES     ('3', '1', '0550', 'R501 ', 'WK', 1, 16, 0, 2.2, 12.4, 0, TO_DATE('05/19/2010', 'mm/dd/yyyy'), TO_DATE('12/31/1900', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
INSERT INTO     op_detail
VALUES     ('3', '1', '0324', 'Y000 ', 'CL', .1, .2, 0, 0, .07, 0, TO_DATE('02/04/2010', 'mm/dd/yyyy'), TO_DATE('02/04/2010', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
INSERT INTO     op_detail
VALUES     ('4', '1', '0324', 'Y000 ', 'CP', .1, .2, 0, 0, .59, 0, TO_DATE('02/06/2004', 'mm/dd/yyyy'), TO_DATE('02/06/2004', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);This is the query I'm working with right now:
SELECT     o.part_nbr               
,          s.major_seq_nbr          AS op_nbr
,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
               WHEN     s.wctr_id     IN ('H211','H212')
               THEN     'Z211'
               ELSE     s.wctr_id
          END                         AS wctr
,          MIN(s.plan_su_rsrc)          AS min_plan_setup
,          AVG(s.plan_su_rsrc)          AS avg_plan_setup
,          MAX(s.plan_su_rsrc)          AS max_plan_setup
,          STDDEV(s.plan_su_rsrc)     AS sdev_plan_setup
,          MIN(s.plan_run_rsrc)     AS min_plan_run
,          AVG(s.plan_run_rsrc)     AS avg_plan_run
,          MAX(s.plan_run_rsrc)     AS max_plan_run
,          STDDEV(s.plan_run_rsrc)     AS sdev_plan_run
,          MIN(s.plan_subc_amt)     AS min_plan_subc
,          AVG(s.plan_subc_amt)     AS avg_plan_subc
,          MAX(s.plan_subc_amt)     AS max_plan_subc
,          STDDEV(s.plan_subc_amt)     AS sdev_plan_subc
,          MIN(s.act_su_rsrc)          AS min_act_setup
,          AVG(s.act_su_rsrc)          AS avg_act_setup
,          MAX(s.act_su_rsrc)          AS max_act_setup
,          STDDEV(s.act_su_rsrc)     AS sdev_act_setup
,          MIN(s.act_run_rsrc)          AS min_act_run
,          AVG(s.act_run_rsrc)          AS avg_act_run
,          MAX(s.act_run_rsrc)          AS max_act_run
,          STDDEV(s.act_run_rsrc)     AS sdev_act_run
,          MIN(s.act_subc_amt)          AS min_act_subc
,          AVG(s.act_subc_amt)          AS avg_act_subc
,          MAX(s.act_subc_amt)          AS max_act_subc
,          STDDEV(s.act_subc_amt)     AS sdev_act_subc     
,          MIN(s.act_start_dt)          AS min_start
,          MAX(s.act_start_dt)          AS max_start
,          MIN(s.dt_completed)          AS min_comp
,          MAX(s.dt_completed)          AS max_comp
,          MIN(s.qty_planned)          AS min_qty_plan
,          AVG(s.qty_planned)          AS avg_qty_plan
,          MAX(s.qty_planned)          AS max_qty_plan
,          STDDEV(s.qty_planned)     AS sdev_qty_plan
,          MIN(s.qty_recvd)          AS min_qty_recvd
,          AVG(s.qty_recvd)          AS avg_qty_recvd
,          MAX(s.qty_recvd)          AS max_qty_recvd
,          STDDEV(s.qty_recvd)          AS sdev_qty_recvd
,          MIN(s.qty_complete)          AS min_qty_comp
,          AVG(s.qty_complete)          AS avg_qty_comp
,          MAX(s.qty_complete)          AS max_qty_comp
,          STDDEV(s.qty_complete)     AS sdev_qty_comp
,          MIN(s.qty_scrap)          AS min_qty_scrap
,          AVG(s.qty_scrap)          AS avg_qty_scrap
,          MAX(s.qty_scrap)          AS max_qty_scrap
,          STDDEV(s.qty_scrap)          AS sdev_qty_scrap
,          MIN(s.qty_on_hold)          AS min_qty_hold
,          AVG(s.qty_on_hold)          AS avg_qty_hold
,          MAX(s.qty_on_hold)          AS max_qty_hold
,          STDDEV(s.qty_on_hold)     AS sdev_qty_hold
,          COUNT(*)                    AS rec_cnt
,          CASE
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
               THEN     '12 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
               THEN     '24 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
               THEN     '36 mos. back'
               ELSE '37 mos. back +'
          END                         AS time_period
FROM          ord_master o
,          op_detail     s
,          (     -- begin in-line view a, to get the min act_start_dt for each order
          SELECT     s1.ord_nbr
          ,          s1.sub_ord_nbr
          ,          MIN     (
                         CASE
                              WHEN     s1.act_start_dt     > TO_DATE('01/01/2000','mm/dd/yyyy')
                              THEN     s1.act_start_dt
                         END
                         )          AS ord_min_start
          FROM          op_detail s1
          GROUP BY     s1.ord_nbr
          ,          s1.sub_ord_nbr
          ) a     -- end in-line view a          
WHERE     o.ord_nbr          = s.ord_nbr
AND          o.sub_ord_nbr     = s.sub_ord_nbr
AND          o.ord_nbr          = a.ord_nbr
AND          o.sub_ord_nbr     = a.sub_ord_nbr
AND          o.ord_type     = 'AA'
AND          o.ord_stat     IN ('CL','OP')
AND          s.oper_stat     IN ('CL','CP')
GROUP BY     o.part_nbr
,          s.major_seq_nbr
,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
               WHEN     s.wctr_id     IN ('H211','H212')
               THEN     'Z211'
               ELSE     s.wctr_id
          END
,          CASE
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
               THEN     '12 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
               THEN     '24 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
               THEN     '36 mos. back'
               ELSE '37 mos. back +'
          END
ORDER BY     o.part_nbr
,          CASE
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
               THEN     '12 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
               THEN     '24 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
               THEN     '36 mos. back'
               ELSE '37 mos. back +'
          END
,          s.major_seq_nbrThis gives me a bunch of descriptive statistics on some data stored in the database, broken into groups by the time period.
I have 7 sets of possible values for the column wctr_id that are groups of similar/same work centers, and should be treated as the same, assuming the ord_nbr, sub_ord_nbr, and major_seq_nbr are the same. In my example case statement above, anytime I find 'H211' or 'H212', I am replacing it with 'Z211', which is my new, unique identifier for any wctr in the group ('H211', 'H212'). I have 7 of these sorts of groups that need to be replaced by a new, unique identifier. Is my CASE statement (noted above) the best way to do this, or is there a better way? These groups of similar-to wctr_id's are not listed in a table anywhere.

Hi,
As always, thanks for posting the CREATE TABLE and INSERT statements; that's very helpful, and leads to faster, better solutions.
Another thing that is helpful, and promotes faster, better solutions, is to simplify your problem.
For example, you have to compute a lot of aggregates, but it looks like you already know how to do that. This problem only involves the CASE expressions, and how they interact with the GROUP BY clause. So just cut out most of the aggregate functions.
Also, it looks like the intricacies of in-line view a have nothing to do with your current problem. For purposes of posting this problem, pretend that a is a regular view, so it doesn't clutter up the main query.
I think your problem could be restated like this:
You already have a query like this:
CREATE OR REPLACE VIEW a
AS
          SELECT     s1.ord_nbr
          ,          s1.sub_ord_nbr
          ,          MIN     (
                         CASE
                              WHEN     s1.act_start_dt     > TO_DATE('01/01/2000','mm/dd/yyyy')
                              THEN     s1.act_start_dt
                         END
                         )          AS ord_min_start
          FROM          op_detail s1
          GROUP BY     s1.ord_nbr
          ,          s1.sub_ord_nbr
SELECT     o.part_nbr               
,          s.major_seq_nbr          AS op_nbr
,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
               WHEN     s.wctr_id     IN ('H211','H212')
               THEN     'Z211'
               ELSE     s.wctr_id
          END                         AS wctr
,          MIN(s.plan_su_rsrc)          AS min_plan_setup
          -- lots of other agtgregates go here in real query
,          CASE
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
               THEN     '12 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
               THEN     '24 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
               THEN     '36 mos. back'
               ELSE '37 mos. back +'
          END                         AS time_period
FROM          ord_master o
,          op_detail     s
,          a          -- in real query, a is an in-line view
WHERE     o.ord_nbr          = s.ord_nbr
AND          o.sub_ord_nbr     = s.sub_ord_nbr
AND          o.ord_nbr          = a.ord_nbr
AND          o.sub_ord_nbr     = a.sub_ord_nbr
AND          o.ord_type     = 'AA'
AND          o.ord_stat     IN ('CL','OP')
AND          s.oper_stat     IN ('CL','CP')
GROUP BY     o.part_nbr
,          s.major_seq_nbr
,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
               WHEN     s.wctr_id     IN ('H211','H212')
               THEN     'Z211'
               ELSE     s.wctr_id
          END
,          CASE
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
               THEN     '12 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
               THEN     '24 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
               THEN     '36 mos. back'
               ELSE '37 mos. back +'
          END
ORDER BY     o.part_nbr
,          CASE
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
               THEN     '12 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
               THEN     '24 mos. back'
               WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
               THEN     '36 mos. back'
               ELSE '37 mos. back +'
          END
,          s.major_seq_nbr
;that produces this output:
`                       MIN_
                       PLAN_
PART_NBR   OP_N WCTR   SETUP TIME_PERIOD
ABC-123    0081 X516      .0 12 mos. back
ABC-123    0130 Z211      .5 12 mos. back
ABC-123    0170 X928      .0 12 mos. back
ABC-123    0324 Y000      .1 12 mos. back
ABC-123    0120 H214      .3 24 mos. back
ABC-123    0122 T203     2.5 24 mos. back
ABC-123    0130 Z211      .5 24 mos. back
ABC-123    0170 X928      .0 24 mos. back
ABC-123    0324 Y000      .1 24 mos. back
ABC-123    0324 Y000      .1 37 mos. back +The output is correct; the problem is, can we get the same results without 2 copies of the wctr CASE expression, and 3 copies of the time_period CASE expression?
Is that a fair description of the problem?
For starters, you can use column aliases in the ORDER BY clause. Unfortunately, that's the only place where you can use column aliases in the same query where they are defined . You can compute them in a sib-query, and then use them in super-queries.
In other words, wouldn't it be nice if we had a table just like op_detail, but with an additional column called wctr? Make a view: either a regular view (especially if wctr, computed the same way, will be used in several different queries) or an in-line view, as shown below.
Wouldn't it be great if there was a table that was just like a, except that it had time_period alreay computed? Make a view: either a regular view or an in-line view, as shown below.
SELECT     o.part_nbr
,     s.major_seq_nbr          AS op_nbr
,     s.wctr
,     MIN(s.plan_su_rsrc)          AS min_plan_setup
     -- lots of other agtgregates go here in real query
,     a2.time_period
FROM     ord_master      o
,     (          -- Begin in-line view s, with data from op_detail
             SELECT  op_detail.*      -- or list all columns needed in main query
          ,     CASE          -- replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
                   WHEN     wctr_id        IN ('H211','H212')
                   THEN     'Z211'
                   ELSE     wctr_id
               END                    AS wctr
          FROM     op_detail
     ) s          -- End in-line view s, with data from op_detail
,     (           -- Begin in-line view a2, to compute time_period
          SELECT  a.*
          ,     CASE
                   WHEN ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                       THEN     '12 mos. back'
                       WHEN ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                       THEN     '24 mos. back'
                       WHEN ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                       THEN     '36 mos. back'
                       ELSE '37 mos. back +'
               END                         AS time_period
          FROM     a          -- in real query, a is an in-line view
     ) a2          -- End in-line view a2, to compute time_period
WHERE     o.ord_nbr     = s.ord_nbr
AND     o.sub_ord_nbr     = s.sub_ord_nbr
AND     o.ord_nbr     = a2.ord_nbr
AND     o.sub_ord_nbr     = a2.sub_ord_nbr
AND     o.ord_type     = 'AA'
AND     o.ord_stat     IN ('CL','OP')
AND     s.oper_stat     IN ('CL','CP')
GROUP BY     o.part_nbr
,          s.major_seq_nbr
,          s.wctr
,          a2.time_period
ORDER BY     o.part_nbr
,          a2.time_period
,          s.major_seq_nbr
;In your example, wctr is the same as wctr_id except for two values. If it was more complicated (e.g., if there were not just 2 values that need to be mapped to 'Z211', but also 3 values to were equivalent to 'Z987', and 1 that was to be treated like 'A012', and 5 that should appear as 'A666', and ...), then you could code all that in a humongeous CASE expression (a nested CASE expression, if it involves more that 128 branches), but it really belongs in a table, where you have the raw wctr_id (like 'H211') in one column, and its corresponding equivalent (such as 'Z211') in another. I know you said you can't create new tables; I'm just pointing this out so you can tell the people who won't let you create new tables that it's a bad idea, likely to cause errors and certain to waste time in the future.

Similar Messages

  • Best way to update a table with disinct values

    Hi, i would really appreciate some advise:
    I need to reguarly perform a task where i update 1 table with all the new data that has been entered from another table. I cant perform a complete insert as this will create duplicate data every time it runs so the only way i can think of is using cursors as per the script below:
    CREATE OR REPLACE PROCEDURE update_new_mem IS
    tmpVar NUMBER;
    CURSOR c_mem IS
    SELECT member_name,member_id
    FROM gym.members;
    crec c_mem%ROWTYPE;
    BEGIN
    OPEN c_mem;
    LOOP
    FETCH c_mem INTO crec;
    EXIT WHEN c_mem%NOTFOUND;
    BEGIN
    UPDATE gym.lifts
    SET name = crec.member_name
    WHERE member_id = crec.member_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
    END;
    IF SQL%NOTFOUND THEN
    BEGIN
    INSERT INTO gym.lifts
    (name,member_id)
    VALUES (crec.member_name,crec.member_id);
    END;
    END IF;
    END LOOP;
    CLOSE c_mem;
    END update_new_mem;
    This method works but is there an easier (faster) way to update another table with new data only?
    Many thanks

    >
    This method works but is there an easier (faster) way to update another table with new data only?
    >
    Almost anything would be better than that slow-by-slow loop processing.
    You don't need a procedure you should just use MERGE for that. See the examples in the MERGE section of the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm
    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*.01)
         WHERE (S.salary <= 8000);

  • Simplist/best way to replace a color with another color?

    I have a series of footage taken at a photography studio where we used purple coloured gels behind 1k fresnels to create spots of purple on the floor and to light the subjects. Floor and background are black.
    There are a few clips where I want to change the purple to another colour (in this case blue), what is the best way to do this? Basically I want to change anything purple to blue, but the purple does have somewhat of a gradient, basically the more purple saturated colours need to become blue.
    What's the best way to go about doing this?

    Take it to Color and use a secondary to make a color selection. You might be able in secondaries to use a hue range selection and change that. Without seeing the images it's difficult to tell. It depends specifically on the colors of the subjects. The problem in your case you're not actually changing a color in the image, but objects that are reflecting the color from gelled lights, and they might not all reflect it in the same way and produce the same colors.

  • What is the best way to manage multiple devices with one iMac - different users with seperate itunes accounts or one mac user with different itune logons and libraries?

    Hello
    I have just purchased an imac which I am very happy with.  In our household we also have two iphones (one mine and one husbands) and one ipod (my sons). We all have individual itunes accounts set up on our previous computer (not a mac). We have sepereate apps and music, although there may be the odd occasion where we would like to share a song (if this is possible) across devices.
    I am just wondering the best way to manage these devices using the new imac.  Should I create individual accounts to logon to the imac, then from within these launch our own itunes accounts and sync our devices with these.  Or should I be using one version of itunes, logging on to this with our different itunes usernames and storing things in libraries.
    Any help would be greatly appreciated. 
    Thanks

    I am presuming that we cannot share downloaded apps and music between accounts because of the copyright issue,
    Though I'm no copyright lawyer, as long as it's within a household, you can share content among users. Such sharing is, absent specific language preventing it not present in the iTunes Store terms of use, generally considered to be "personal use". So you can share apps and music amongst your users on your computer and with their devices. You just can't give any of that content to friends or relatives who don't live with you.
    What I am not clear on, it making sure that this appears in each itunes account - is it easy to find the file storage folders that match the itunes accounts and what would these be?
    The iTunes library and files are by default in a user's Home/Music folder. But you don't have to find the folder; in fact putting a file into the folder yourself won't add the file to iTunes. Just drag the file into the iTunes window. iTunes will copy it to the correct location.
    Regards.

  • Best way to replace hard drive with Time Machine

    Hello, I searched dozens of threads before posting but I didn't find my specific topic.
    I have a G5 (single CPU) with two internal hard drives plus one external drive. The original hard drive is only 80gb and it has been quite full for several years now. I purchased a second internal drive (150gb) about 3 or 4 years ago and have been storing all my files video and data files on the second drive. This created some additional space on the primary drive, but not much. I started off with OX 10.1 back in 2003 and have purchased the upgrades all the way to OX 10.5.4. I also have about 14000 photos in iPhoto that are stored on the primary drive because I can't figure out how to move my library to the second drive (where there is more space).
    About a year ago, I purchased an iomega 500gb external drive (USB 2.0) that runs Time Machine.
    I have not had any issues with any of the drives except for running out of space on the main drive. I accidentally deleted some of my wife's files once and used Time Machine as advertised.
    My main drive has 4.7gb free
    My second drive has 87gb free
    My Time Machine drive has 205gb free.
    I purchased a new 500gb internal drive.
    I think my G5 will only take 2 internal drives total, so the original 80gb drive needs to go. How do I accomplish this? Should I make my 150gb the main drive, since it will be the smallest and therefore maybe the fastest for running the OS? If size of the drive doesn't matter, then should I just remove the 80gb drive, install the new 500gb in it's place and then boot using the OS X10.5 disk?
    I suppose I could just let Time Machine restore the system, but do I really want OS X10.1 with a bunch of upgrades? It looks like my OS X 10.5 disk is a full version (it doesn't say 'upgrade only') on the box... Wouldn't my computer run better with a fresh OS X install and if so, is there a way to let Time Machine re-install my apps and user settings? I think I am running iLife 06 (which ever one has iMovieHD...) I also have Final Cut Express HD, CorelDraw suite and NeoOffice. Everything else is how the computer came back in 2003. I've never had any issues, so I am more than a little concerned that I am going to mess something up. You know that saying...."If it ain't broke....'
    Any advice?
    Regards

    You do indeed have only two internal drive slots in your G5. To avoid having to try restoring everything from your TM backup what you could do is to be sure you force a final TM backup of the 80 GB drive before removing it. Install the new drive. Prepare the new drive - I suggest the following:
    Extended Hard Drive Preparation
    1. Boot from your Leopard Installer Disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area. If it does not say "Verified" then the drive is failing or has failed and will need replacing. SMART info will not be reported on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID (only required for Intel Macs) then click on the OK button. Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Upon completion of formatting quit DU and return to the installer. Now complete your installation of OS X. During this process you will be asked if you want to do a full restore from a TM backup. Skip this option. Once the installation has completed the computer will restart. After restarting you will see the Setup Assistant. When you've completed the Setup Assistant you will be given the option to migrate from a connected TM backup drive. Select this option. You can then migrate your Home folder, applications, and preferences. There is only one important caveat to this. When completing the setup you are asked to provide a username and password for the startup admin account. Do not use the same username as the Home folder you will migrate. Select a different username (short name is what it is also called.)
    Once the migration has completed you can log out of the startup admin account and log into the migrated account. You can then delete the startup account unless you choose to keep it around for test purposes.
    This process will not restore anything else from your backup except the Home folder, applications, and preferences. If there are items in your Home folder you would prefer not to migrate, then move them to the other hard drive.

  • Best way to reuse a layout with different values?

    I want to reuse the code of the <div id="placeInfo"> on the next page (place.xhtml). I simplified it's code for this question.
    Of course I can use <ui:include> for <div id="placeInfo"> but on the next page I would need e.g. #{myBean.selectedPlace.name} instead of #{place.name}.
    Any smart idea how to do this efficiently?
    <ui:repeat value="#{myBean.places}" var="place">
        <p:commandLink action="place?faces-redirect=true" ajax="false">
            <f:setPropertyActionListener value="#{place}" target="#{myBean.selectedPlace}" />
            <div id="placeInfo">
                #{place.name}
                #{place.openHours}
            </div>
        </p:commandLink>
    </ui:repeat>

    Research composite components. Its a little cumbersome to do these things in jsf to be honest. I just copypaste the xhtml content most of the times. Its not like it will save you time to turn this into a reusable component.

  • Best way to replace squirrel mail with roundcube?

    Hi,
         I have managed to succsessfully configure and use Roundcube, on a test ubuntu server that I have, to access our OS X mail server (10.6).
    What I would like to do is seemlessly (as far as the users are concerened) get the 'Mail' link that appears when they login to their page on the mail servers website take them to roundcube. The links resolves to mail1.************.com/webmail. Could I just install roundcube into this folder?
    I beleave the folder is /Library/webserver/documents/webmail
    Thanks.

    You could put a very simple html page in the webmail folder and setup a standard Apache website for it and then that page could if needed have a html redirect to another address. You would need to make sure the normal Squirrelmail function is turned off.

  • Best way to replace move in iDVD project?

    Hello,
    I have an iDVD project started and realized I wanted to change a couple details in the iMovie I imported to the project. I can go back and correct the iMovie, but what's the best way to replace the current movie in the iDVD project with the revised iMovie? I'd rather not have to start a new iDVD project and add the pictures to the drop zones etc. Thank you, Rick H.

    I forgot that if I hit 'return' the forum cuts what I write. Once I've got a movie in an iDVD project, what's the best way to replace that movie with a revised version (if I realize I need to make a couple changes in iMovie? Do you just go to the map and manually delete everything except the main title? Thanks, Rick.

  • Best way to Replace OLD Time Capsule with a new one

    What is the best way to replace an old Time capsule with a new Time Capsule in an existing wireless network?

    IMHO..
    Start over..
    Put the new TC in place and configure .. completely differently to the old one. That means you have to go around and reset everything to connect if you use wireless.. and you should forget all the old configuration beforehand.
    You can of course try and slip it in using identical names and identical settings.. but the computers are not fooled.. the BSSID is different. And other issues tend to arise.
    Use naming that is short, no spaces and pure alphanumeric.
    See Pondini post C9 here.
    http://pondini.org/TM/Troubleshooting.html
    It may take more time to start with.. depending on how many devices you have.. but in the end, you can get much less problems out the other side.. which are extraordinarily hard to diagnose and fix..
    But that is IMHO.. others are welcome to dispute that and may find a full swap using old settings copied to a file and copied back to the new TC work fine.
    There are any number of posts around about doing just that.
    I will post one if I see it..
    I do confess to being a bit of a purist when it comes to this stuff.. but then I used to do computer support and trying to fix the messes people got themselves into .. inevitably they tried to cut corners.. instead of doing the setup from scratch.

  • The best way to replace the internal hard drive

    Hi,
    I have a MacBook with a 160gb hard drive which has been partitioned into two partitions one for OSX (130gb) and the other for Windows 7(30gb) and as you can imagine 30gigs for windows is almost nothing, the OS itself is taking a big percentage of its capacity, so I would like to expand both partitions by having a bigger hard drive installed but I was wondering what would bethe best way to do this so I don’t have to reinstall OSX and Windows 7, I have heard about Super Duper for OSX I don’t know if a similar software exists for Windows, well I don't even know if this is the way to go. So my question would is...
    What would be the best way to replace an internal hard drive and have everything moved including the Operating Systems (OSX Lion and Windows7)?
    Can someone be so kind and tell me the procedure I should follow to accomplish this task? I’m not expecting a step by step tutorial but if you could list the tools needed and a brief procedure it would be greatly appreciated.
    Oh, I’m using Boot Camp for the Windows 7 installation.
    Thanks a lot.

    For a hard drive try Newegg.com http://www.newegg.com/Store/SubCategory.aspx?SubCategory=380&name=Laptop-Hard-Dr ives&Order=PRICE
    Or OWC  http://eshop.macsales.com/shop/hard-drives/2.5-Notebook/
    Here's instructions on replacingthe hard drive http://creativemac.digitalmedianet.com/articles/viewarticle.jsp?id=45088
    To transfer your current hard drive I like the free application Carbon Copy Cloner. It makes a bootable copy of everything on your hard drive http://www.bombich.com/index.html You'll need a cheap SATA external hard drive case. Put the new drive in the case then partition and format the new drive and clone your old drive to the new one. Check that it's set up right by booting up from the external drive. Then replace your old hard drive with the new one.
    Here's a cheap SATA external hard drive case on eBay http://cgi.ebay.com/USB-2-5-SATA-HDD-HARD-DRIVE-EXTERNAL-ENCLOSURE-CASE-BOX-/120 636286623?pt=PCC_Drives_Storage_Internal&hash=item1c167ba69f
    For copying the Windows partition I like WinClone http://download.cnet.com/Winclone/3000-2242_4-172338.html
    After you've installed your Mac OS with Carbon Copy Cloner (or SuperDuper) on the new drive create a new Windows partition with Boot Camp and copy your WinClone copy to it with Winclone.

  • What is the best way to replace the Inline Views for better performance ?

    Hi,
    I am using Oracle 9i ,
    What is the best way to replace the Inline Views for better performance. I see there are lot of performance lacking with Inline views in my queries.
    Please suggest.
    Raj

    WITH plus /*+ MATERIALIZE */ hint can do good to you.
    see below the test case.
    SQL> create table hx_my_tbl as select level id, 'karthick' name from dual connect by level <= 5
    2 /
    Table created.
    SQL> insert into hx_my_tbl select level id, 'vimal' name from dual connect by level <= 5
    2 /
    5 rows created.
    SQL> create index hx_my_tbl_idx on hx_my_tbl(id)
    2 /
    Index created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(user,'hx_my_tbl',cascade=>true)
    PL/SQL procedure successfully completed.
    Now this a normal inline view
    SQL> select a.id, b.id, a.name, b.name
    2 from (select id, name from hx_my_tbl where id = 1) a,
    3 (select id, name from hx_my_tbl where id = 1) b
    4 where a.id = b.id
    5 and a.name <> b.name
    6 /
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=2 Bytes=48)
    1 0 HASH JOIN (Cost=7 Card=2 Bytes=48)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    3 2 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    4 1 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    5 4 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    Now i use the with with the materialize hint
    SQL> with my_view as (select /*+ MATERIALIZE */ id, name from hx_my_tbl where id = 1)
    2 select a.id, b.id, a.name, b.name
    3 from my_view a,
    4 my_view b
    5 where a.id = b.id
    6 and a.name <> b.name
    7 /
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=8 Card=1 Bytes=46)
    1 0 TEMP TABLE TRANSFORMATION
    2 1 LOAD AS SELECT
    3 2 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    4 3 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    5 1 HASH JOIN (Cost=5 Card=1 Bytes=46)
    6 5 VIEW (Cost=2 Card=2 Bytes=46)
    7 6 TABLE ACCESS (FULL) OF 'SYS_TEMP_0FD9D6967_3C610F9' (TABLE (TEMP)) (Cost=2 Card=2 Bytes=24)
    8 5 VIEW (Cost=2 Card=2 Bytes=46)
    9 8 TABLE ACCESS (FULL) OF 'SYS_TEMP_0FD9D6967_3C610F9' (TABLE (TEMP)) (Cost=2 Card=2 Bytes=24)
    here you can see the table is accessed only once then only the result set generated by the WITH is accessed.
    Thanks,
    Karthick.

  • What is the BEST way to get my macbook with lion on it, to communicate with my Canon 40D camera?

    What is the BEST way to get my macbook with lion on it, to communicate with my Canon 40D camera? It says the utility disk is a PowerPC app and that is no longer supported. What do I do now? I can't upload photos from my camera.

    Also, I had the same problem happen when I tried to install an older version of Corel Painter. Are Macbook Pro users just NOT supposed to be able to use their laptops for the purposes they are best designed for?
    -Frustrated new Mac user

  • Best way to fill a datagird with A LOT of data?

    What's the best way to fill a datagrid with A LOT of data.
    I'm talking about something like 10,000 rows. Can the datagrid
    handle it? No screen is large enough to show 10,000 records..... is
    there a way to load 50, and then when a user scrolls down it loads
    the next 50 etc...?

    Right. It's not recommended that you load 10,000 rows into
    the datagrid at once. Using the data management service with paging
    enabled is a much better solution. See the Configuring the Data
    Management Service chapter in the Flex2 Developer's Guide for more
    info.

  • Best way to build a website with hundreds of pages

    What is the best way to build a website with hundreds of pages that include businesses in every city of the U.S. I will be building it in Dreamweaver CS4 and pulling the data from an MS Excel spreadsheet.
    I started building it by building the first page and then saving a new page with new data and so on.
    There must be a way to pull from the Excel doc without copying and pasting each page of data, and there must be a way to build this site smaller and easier to make changes when needed.
    Thanks

    You already have other people addressing the DB issues - so I will bring up the other... You are just saving a copy as a new page and then copy and pasting the changed content into  it?
    What you want to do is take the first page, once you have your design done - and save it as a template (file - save as - Dreamweaver Template).
    Then you want to select the areas (most likely the divs you have content in) that will have content changed, and select the div or p or whatever element... and go to Insert - Template Objects - Editible Region.
    Make sure you don't made editable the areas that are the primary design - such as a logo element, a header image, the navigation etc.  If you want to change those - you would do so by making the change on the template, and then it will automatically update all pages made based on that template.
    Once you are done setting up the templates - go to your new page and choose Modify - Templates - Apply Template To Page
    Select the template you just created (note it will be placed inside of a new folder titled "templates" automatically by Dreamweaver).
    Now, any of the areas you selected to add different content into will be selectable, and you can copy/paste or however you are doing so.
    Good luck

  • Best way to share a video with someone in another city...

    What is the best way to share a video with someone in another city?
    I know that FCPX contains all sorts of share options which create different resolutions and file sizes appropriate for different sites like YouTube, Facebook, and others.  But how to create the videos really isn't the problem.
    I want to know how to share them.  I'm creating videos that are ultimately to be viewed on the internet.  When I have a completed video, I want to show it to the person who it is for before I finalize it.  I know that if it very small, I could email it.  And if it's larger, I could use something like Dropbox.  But I don't necessarily want them to have a copy of it (though I could do that and put a watermark on it).
    I'd like to upload it to a site like YouTube or Vimeo, but those sites seem to be about sharing videos with a wide audience.  I know you can make a video private on YouTube, but, from what I've read, they permanently have the right to use the content, which I definitely don't want.
    So what's the best way to do this?  I'm going to have to do it regularly, so I'm willing to pay for a service if it assures privacy and does not try to assert some right to my content.
    I know there is an issue to be considered with people screen capturing content, but I'll use a watermark to lessen the chances of that.

    Hi Russ--
    I'll have to read through Vimeo's terms of service, but I have to think they're asserting some right to the content like YouTube does.
    Plus, these are commercial videos, and I don't think they allow that.  Of course, if they're private, I'm obviously not trying to sell anything.  But I have to think that it somehow is against their TOS since me posting a bunch of private videos that nobody can see really doesn't do them any good at all.

Maybe you are looking for

  • ITunes Match - Two Apple IDs but the Same Person

    So before the days of iCloud, I originally used my AOL email as my Apple ID. Then when I signed up for iCloud, I started using my .Mac email as my new Apple ID. Today, I just signed up for iTunes Match using my .Mac Apple ID. Somehow throughout this

  • Send a mail if no file in Sender File Adapter

    Hello guys, I have one doubt. I have a sender File adapter with FTP transfer protocol. I want to pull the file every 24 hours. If the file does not exist, there is any way to have an error and send a mail to the client? Is a requierement to do one in

  • How can I export m2ts footage with 5.1 audio in PP CS5.5?

    Dear All! I have a 90 minutes project which made from 4 sequence. Sequence settings are the followings : AVCHD 1080p 25fps square pixels , 5.1 channel master audio. I made the sequences from avchd file-s, which recorded with Sony HDR-CX700V with AVCH

  • Additional Action process

    Dear All, I know the concept of additional action and someone asked me to run the programe RPUEVSUP to activate the same. When I run the programe it shows 'already activated'. But again if I try to do the same by removing the check mark in 'test run'

  • One xml, multiple xsl, multiple xslt, one output

    Hi, I have one xml file, 3 xsl files, and want to output (append) to a text file. I can only get a result when I run one xsl against the xml, if I try adding new xsl and new Transform instances, I get a whole host of errors. The bits in bold are what