[8i] not to simplify this query?

In my application, I need to pick up three possible prices for each part number in an array.
The three possible prices that I need to recover are:
(1) the price paid on the order more recently closed,
(2) the price mentioned on the first pending order, and
(3) the price on the furthest on pending order.

However, there is a complication in that. Orders include the part number, but may also include a prefix of 4 characters (always the same) on a reference number which should be treated the same as the reference database. For example, "DSB-part1" should be considered "part1", "DSB-part2" should be regarded as 'part 2', etc.

In addition, it is quite possible for several orders expected or closed on the same day, and I want to only return the price of one of these lines for each of the 3 methods of pricing.

(Technically, there is another level of complication to this, but if I have problems with it later, I'll create a new job for him...)

Some examples of data:
CREATE TABLE     part
(     part_no          VARCHAR2(9)     NOT NULL,
     part_desc     VARCHAR2(25),
     qty_instock     NUMBER,
     CONSTRAINT part_pk PRIMARY KEY (part_no)
);

INSERT INTO     part
VALUES ('part1    ','description 1 here',5);
INSERT INTO     part
VALUES ('part2    ','description 2 here',10);
INSERT INTO     part
VALUES ('part3    ','description 3 here',0);

CREATE TABLE     ords
(     ord_no               NUMBER NOT NULL,
     ord_part_no          VARCHAR2(9),
     date_closed          DATE,
     orig_dock_date          DATE,
     date_due_instock     DATE,
     unit_price          NUMBER,
     qty_order          NUMBER,
     ord_stat          VARCHAR2(2),
     CONSTRAINT ords_pk PRIMARY KEY (ord_no)
);

INSERT INTO     ords
VALUES (1,'part1    ',To_Date('01/01/2009','mm/dd/yyyy'),To_Date('12/01/2008','mm/dd/yyyy'),To_Date('12/15/2008','mm/dd/yyyy'),100,10,'CL');
INSERT INTO     ords
VALUES (2,'part1    ',To_Date('01/31/2009','mm/dd/yyyy'),To_Date('01/01/2009','mm/dd/yyyy'),To_Date('01/05/2009','mm/dd/yyyy'),105,15,'CL');
INSERT INTO     ords
VALUES (3,'part1    ',To_Date('01/31/2009','mm/dd/yyyy'),To_Date('01/15/2009','mm/dd/yyyy'),To_Date('01/20/2009','mm/dd/yyyy'),100,20,'CL');
INSERT INTO     ords
VALUES (4,'part1    ',To_Date('12/31/1900','mm/dd/yyyy'),To_Date('01/15/2009','mm/dd/yyyy'),To_Date('01/25/2009','mm/dd/yyyy'),103,10,'OP');
INSERT INTO     ords
VALUES (5,'ORD-part1',To_Date('12/31/1900','mm/dd/yyyy'),To_Date('01/20/2009','mm/dd/yyyy'),To_Date('01/31/2009','mm/dd/yyyy'),101,10,'OP');

INSERT INTO     ords
VALUES (6,'ORD-part2',To_Date('01/01/2009','mm/dd/yyyy'),To_Date('12/01/2008','mm/dd/yyyy'),To_Date('12/15/2008','mm/dd/yyyy'),100,10,'CL');
INSERT INTO     ords
VALUES (7,'part2    ',To_Date('01/31/2009','mm/dd/yyyy'),To_Date('01/01/2009','mm/dd/yyyy'),To_Date('01/05/2009','mm/dd/yyyy'),105,15,'CL');
INSERT INTO     ords
VALUES (8,'ORD-part2',To_Date('01/31/2009','mm/dd/yyyy'),To_Date('01/15/2009','mm/dd/yyyy'),To_Date('01/20/2009','mm/dd/yyyy'),100,20,'CL');
INSERT INTO     ords
VALUES (9,'part2    ',To_Date('12/31/1900','mm/dd/yyyy'),To_Date('01/15/2009','mm/dd/yyyy'),To_Date('01/25/2009','mm/dd/yyyy'),103,10,'OP');
INSERT INTO     ords
VALUES (10,'ORD-part2',To_Date('12/31/1900','mm/dd/yyyy'),To_Date('01/20/2009','mm/dd/yyyy'),To_Date('01/31/2009','mm/dd/yyyy'),101,10,'OP');

INSERT INTO     ords
VALUES (11,'part3    ',To_Date('01/01/2009','mm/dd/yyyy'),To_Date('12/01/2008','mm/dd/yyyy'),To_Date('12/15/2008','mm/dd/yyyy'),100,10,'CL');
INSERT INTO     ords
VALUES (12,'part3    ',To_Date('01/31/2009','mm/dd/yyyy'),To_Date('01/01/2009','mm/dd/yyyy'),To_Date('01/05/2009','mm/dd/yyyy'),105,15,'CL');
INSERT INTO     ords
VALUES (13,'ORD-part3',To_Date('01/31/2009','mm/dd/yyyy'),To_Date('01/15/2009','mm/dd/yyyy'),To_Date('01/20/2009','mm/dd/yyyy'),100,20,'CL');
INSERT INTO     ords
VALUES (14,'ORD-part3',To_Date('12/31/1900','mm/dd/yyyy'),To_Date('01/15/2009','mm/dd/yyyy'),To_Date('01/25/2009','mm/dd/yyyy'),103,10,'OP');
INSERT INTO     ords
VALUES (15,'part3    ',To_Date('12/31/1900','mm/dd/yyyy'),To_Date('01/20/2009','mm/dd/yyyy'),To_Date('01/31/2009','mm/dd/yyyy'),101,10,'OP');
And here's my ugly query to get the results I want. It can be simplified?
SELECT     p.part_no
,     p.part_desc
,     p.qty_instock
,     a2.unit_price          AS last_closed_price
,     a2.qty_order          AS last_closed_qty
,     a2.date_closed          AS last_closed_date
,     b2.unit_price          AS first_open_price
,     b2.qty_order          AS first_open_qty
,     b2.date_due_instock     AS first_open_date
,     c2.unit_price          AS last_open_date
,     c2.qty_order          AS last_open_qty
,     c2.date_due_instock     AS last_open_date
FROM     part p
,     (
     SELECT     lc.part_no
     ,     lc.unit_price                                             
     ,     lc.qty_order
     ,     lc.date_closed
     ,     ROW_NUMBER() OVER(PARTITION BY lc.part_no ORDER BY lc.orig_dock_date DESC)     AS rnk_nbr
     FROM     (
          SELECT     CASE
                    WHEN     SUBSTR(o.ord_part_no,1,4)     = 'ORD-'
                    THEN     SUBSTR(o.ord_part_no,5)
                    ELSE     o.ord_part_no
               END                                        AS part_no
          ,     o.date_closed
          ,     o.orig_dock_date
          ,     o.unit_price
          ,     o.qty_order
          FROM     ords o
          ) lc     --for last closed
     ,     (
          SELECT     a.part_no
          ,     MAX(a.date_closed)     AS last_closed_date
          FROM     (
               SELECT     CASE
                         WHEN     SUBSTR(o.ord_part_no,1,4)     = 'ORD-'
                         THEN     SUBSTR(o.ord_part_no,5)
                         ELSE     o.ord_part_no
                    END                                        AS part_no
               ,     o.date_closed
               FROM     ords o
               ) a
          GROUP BY     a.part_no
          ) a1
     WHERE     lc.part_no     = a1.part_no
     AND     lc.date_closed     = a1.last_closed_date
     ) a2
,     (
     SELECT     fo.part_no
     ,     fo.unit_price                                             
     ,     fo.qty_order
     ,     fo.date_due_instock
     ,     ROW_NUMBER() OVER(PARTITION BY fo.part_no ORDER BY fo.orig_dock_date DESC)     AS rnk_nbr
     FROM     (
          SELECT     CASE
                    WHEN     SUBSTR(o.ord_part_no,1,4)     = 'ORD-'
                    THEN     SUBSTR(o.ord_part_no,5)
                    ELSE     o.ord_part_no
               END                                        AS part_no
          ,     o.date_due_instock
          ,     o.orig_dock_date
          ,     o.unit_price
          ,     o.qty_order
          FROM     ords o
          WHERE     o.ord_stat     = 'OP'
          ) fo     --for first open
     ,     (
          SELECT     b.part_no
          ,     MIN(b.date_due_instock)     AS first_open_date
          FROM     (
               SELECT     CASE
                         WHEN     SUBSTR(o.ord_part_no,1,4)     = 'ORD-'
                         THEN     SUBSTR(o.ord_part_no,5)
                         ELSE     o.ord_part_no
                    END                                        AS part_no
               ,     o.date_due_instock
               FROM     ords o
               WHERE     o.ord_stat     = 'OP'
               ) b
          GROUP BY     b.part_no
          ) b1
     WHERE     fo.part_no          = b1.part_no
     AND     fo.date_due_instock     = b1.first_open_date
     ) b2
,     (
     SELECT     lo.part_no
     ,     lo.unit_price                                             
     ,     lo.qty_order
     ,     lo.date_due_instock
     ,     ROW_NUMBER() OVER(PARTITION BY lo.part_no ORDER BY lo.orig_dock_date DESC)     AS rnk_nbr
     FROM     (
          SELECT     CASE
                    WHEN     SUBSTR(o.ord_part_no,1,4)     = 'ORD-'
                    THEN     SUBSTR(o.ord_part_no,5)
                    ELSE     o.ord_part_no
               END                                        AS part_no
          ,     o.date_due_instock
          ,     o.orig_dock_date
          ,     o.unit_price
          ,     o.qty_order
          FROM     ords o
          WHERE     o.ord_stat     = 'OP'
          ) lo     --for last open
     ,     (
          SELECT     c.part_no
          ,     MAX(c.date_due_instock)     AS last_open_date
          FROM     (
               SELECT     CASE
                         WHEN     SUBSTR(o.ord_part_no,1,4)     = 'ORD-'
                         THEN     SUBSTR(o.ord_part_no,5)
                         ELSE     o.ord_part_no
                    END                                        AS part_no
               ,     o.date_due_instock
               FROM     ords o
               WHERE     o.ord_stat     = 'OP'
               ) c
          GROUP BY     c.part_no
          ) c1
     WHERE     lo.part_no          = c1.part_no     --EDIT: changed from l1 to c1
     AND     lo.date_due_instock     = c1.last_open_date     --EDIT: changed from l1 to c1
     ) c2
WHERE     p.part_no     = a2.part_no
AND     a2.part_no     = b2.part_no
AND     b2.part_no     = c2.part_no
AND     a2.rnk_nbr     = 1
AND     b2.rnk_nbr     = 1
AND     c2.rnk_nbr     = 1
And here are the results, I expect to get, according to data from the sample:
.                         LAST_     LAST_     LAST_          FIRST_     FIRST_     FIRST_          LAST_     LAST_     LAST_
.                    QTY_     CLOSED_     CLOSED_     CLOSED_          OPEN_     OPEN_     OPEN_          OPEN_     OPEN_     OPEN_
PART_NO     PART_DESC          INSTOCK     PRICE     QTY     DATE          PRICE     QTY     DATE          PRICE     QTY_     DATE_
---------------------------------------------------------------------------------------------------------------------------------
part1     description 1 here     5     100     20     1/31/2009     103     10     1/25/2009     101     10     1/31/2009
part2     description 2 here     10     100     20     1/31/2009     103     10     1/25/2009     101     10     1/31/2009
part3     description 3 here     0     100     20     1/31/2009     103     10     1/25/2009     101     10     1/31/2009
Published by: user11033437 on February 5, 2010 08:48
Correction of errors (see the comments in the request above for changes)

Hello

It is a little bit shorter than what you have posted, probably more effective and (in my opinion) much easier to debug and maintain:

SELECT       p.part_no
,       p.part_desc
,       p.qty_instock
,       o.last_closed_price
,       o.last_closed_qty
,       o.last_closed_date
,       o.first_open_price
,       o.first_open_qty
,       o.first_open_date
,       o.last_open_price
,       o.last_open_qty
,       o.last_open_date
FROM       part          p
,       (          -- Begin in-line view o for pivoted order data
           SELECT    part_no
           ,          MAX (CASE WHEN lc_num = 1 THEN unit_price           END)  AS last_closed_price
           ,          MAX (CASE WHEN lc_num = 1 THEN qty_order              END)  AS last_closed_qty
           ,          MAX (CASE WHEN lc_num = 1 THEN date_closed            END)  AS last_closed_date
           ,          MAX (CASE WHEN fo_num = 1
                                AND  ord_stat = 'OP'  THEN unit_price       END)  AS first_open_price
           ,          MAX (CASE WHEN fo_num = 1
                                AND  ord_stat = 'OP'  THEN qty_order        END)  AS first_open_qty
           ,          MAX (CASE WHEN fo_num = 1
                                AND  ord_stat = 'OP'  THEN date_due_instock END)  AS first_open_date
           ,          MAX (CASE WHEN lo_num = 1
                                AND  ord_stat = 'OP'  THEN unit_price       END)  AS last_open_price
           ,          MAX (CASE WHEN lo_num = 1
                                AND  ord_stat = 'OP'  THEN qty_order        END)  AS last_open_qty
           ,          MAX (CASE WHEN lo_num = 1
                                AND  ord_stat = 'OP'  THEN date_due_instock END)  AS last_open_date
           FROM     (       -- Begin in-line view to get lc_, fo_, lo_num
                         SELECT    gpo.*
                   ,           ROW_NUMBER () OVER ( PARTITION BY  part_no
                                                    ORDER BY        date_closed          DESC
                                      ,            ord_no               DESC
                                    )      AS lc_num
                   ,           ROW_NUMBER () OVER ( PARTITION BY  part_no
                                                    ORDER BY        CASE
                                                  WHEN  ord_stat = 'OP'
                                                  THEN  1
                                                  ELSE  2
                                              END
                                      ,           orig_dock_date
                                      ,            ord_no
                                    )      AS fo_num
                   ,           ROW_NUMBER () OVER ( PARTITION BY  part_no
                                                    ORDER BY        CASE
                                                  WHEN  ord_stat = 'OP'
                                                  THEN  1
                                                  ELSE  2
                                              END
                                      ,           orig_dock_date          DESC
                                      ,            ord_no               DESC
                                    )      AS lo_num
                   FROM      (       -- Begin in-line view gpo to get part_no
                                  SELECT  ords.*
                           ,       RTRIM ( CASE
                                        WHEN  ord_part_no  LIKE 'ORD-%'
                                                  THEN  SUBSTR (ord_part_no, 5)
                                                  ELSE  ord_part_no
                                                 END
                                   )               AS part_no
                           FROM       ords
                              )     gpo   -- End in-line view gpo to get part_no
                     )      -- End in-line view to get lc_, fo_, lo_num
           GROUP BY  part_no
       ) o          -- End in-line view o for pivoted order data
WHERE       RTRIM (p.part_no)     = o.part_no
ORDER BY  p.part_no
;

Whenever you want to have a WHERE clause only applies to certain columns, think about a pivot and expression BOX.

Is there a reason to have raw triling part_no or ord_part_no?

Published by: Frank Kulash, February 5, 2010 13:26

After this announcement, I saw that Max had posted essentially the same query.
In general, where the solution of Max seems more simple, I like her way better.
The only possible exception is tested for "OP" at the derivation of the values first_open and last_open. If none of the lines to an ord_stat part_no = "OP", solution of Max will be used a the lines with another ord_stat. That does not occur in the sample data, and I don't know if this is still possible in your application, but if this is the case, I don't know this isn't what you want.

Tags: Database

Similar Questions

  • Can anyone simplify this query

    Here's a DOF from two tables

    1. CREATE TABLE (EMPL)
    NUMBER OF SNO
    ENAME VARCHAR2 (25).
    USE VARCHAR2 (25).
    KEY ELEMENTARY SCHOOL (SNO)
    );

    2. CREATE TABLE EMPL_DET)
    NUMBER OF SNO
    SAL VARCHAR2 (25)
    );


    Here are tables LMD
    INSERT INTO EMPL (SNO, ENAME, JOB) VALUES (1, 'SMITH', 'CLERK');
    INSERT INTO EMPL (SNO, ENAME, JOB) VALUES (2, 'SMITH', 'MANAGER');
    INSERT INTO EMPL (SNO, ENAME, JOB) VALUES (3, 'TOM', 'CLK');

    INSERT INTO EMPL_DET (SNO, SAL) VALUES (1, '1000');
    INSERT INTO EMPL_DET (SNO, SAL) VALUES (2, "10000");
    INSERT INTO EMPL_DET (SNO, SAL) VALUES (3, '900');


    I want to calculate TotalSAL (column: empl_det.) SAL) of each employee (empl.ename) with job-description (empl.job).

    Means I want following the lines of output
    1.(Job,TotalSAL,Ename)-> (CLERK, 11000, SMITH)
    2->.(Job,TotalSAL,Ename) (MANAGER, 11000, SMITH)
    3->.(Job,TotalSAL,Ename) (CLK, 900, TOM)

    I tried to write down to unique ename

    Select JOB, x.sal, ename in empl,
    (
    Select sum (sal) sal empl_det where sno in
    (select sno to empl where ename = 'SMITH')
    ) x
    where ename = 'SMITH '.
    order by ename

    each ename, I draw from this query. How can I make the ename list (TOM SMITH) to this request?
    Or can anyone simplify this query?

    Hello

    in this case, you need to use is analytical functions:

    that is to say:

      SELECT e.job, SUM (d.sal) OVER (PARTITION BY e.ename) AS "TotalSal"
           , e.ename
        FROM empl e, empl_det d
       WHERE d.sno = e.sno AND e.ename IN ('SMITH', 'TOM')
    ORDER BY e.ename;
    
    JOB                         TotalSal ENAME
    ------------------------- ---------- -------------------------
    CLERK                          11000 SMITH
    MANAGER                        11000 SMITH
    CLK                              900 TOM                      
    

    Kind regards.
    Al

    Published by: Alberto Faenza on 27 November 2012 15:34
    Corrected query

  • How to simplify this query in sql simple select stmt

    Hello

    Please simplify the query

    I want to convert this query in a single select statement. Is this possible?
    If uarserq_choice_ind is not null then

    Select ubbwbst_cust_code
    From ubbwbst,utrchoi
    Where utrchoi_prop_code=ubbwbst_cancel_prod
    Else

    Select max(utvsrvc_ranking)
    From utvsrvc,ubbwbst
    Where utvsrvc_code=ubbwbst_cancel_prod
    End if
    Select ubbwbst_cust_code as val
    From   ubbwbst,utrchoi
    Where  utrchoi_prop_code=ubbwbst_cancel_prod
    AND    uarserq_choice_ind is not null
    union all
    Select max(utvsrvc_ranking) as val
    From   utvsrvc,ubbwbst
    Where  utvsrvc_code=ubbwbst_cancel_prod
    and    uarserq_choice_ind is null
    

    Without more information, we are unable to combine the two queries in 1 without a union.
    Looks like you select values totally disperate of totally different tables

  • Simplify this query

    When I run this query, it will be 1 hour to run it. can we change this query to do this?
    SELECT /*+ CHOOSE */a.*, b.*
      FROM (SELECT (  TO_DATE (ucraudt_new_value, 'DD-MON-YYYY')
                    - TO_DATE (ucraudt_old_value, 'DD-MON-YYYY')
                   ) AS diff,
                   ucraudt.*
              FROM ucraudt
             WHERE ucraudt_column_code = '1GED'
               AND ucraudt_new_value IS NOT NULL
               AND ucraudt_old_value IS NOT NULL
               AND ucraudt_user_id LIKE 'UCPVCRV%') a,
           ucrserv b
    WHERE a.diff > 74
       AND a.ucraudt_cust_code = b.ucrserv_cust_code
       AND a.ucraudt_prem_code = b.ucrserv_prem_code
       AND b.ucrserv_status_ind = 'A'

    Try following

    SELECT
         a.*, b.*
    FROM
           ucraudt a,
           ucrserv b
     WHERE (TO_DATE (a.ucraudt_new_value, 'DD-MON-YYYY') - TO_DATE (a.ucraudt_old_value, 'DD-MON-YYYY'))  > 74
       AND a.ucraudt_cust_code = b.ucrserv_cust_code
       AND a.ucraudt_prem_code = b.ucrserv_prem_code
       AND b.ucrserv_status_ind = 'A'
       and a.ucraudt_column_code = '1GED'
       AND a.ucraudt_new_value IS NOT NULL
       AND a.ucraudt_old_value IS NOT NULL
       AND a.ucraudt_user_id LIKE 'UCPVCRV%' 
    

    Also post the query execution plan

  • Dialog box that says ' Creative Cloud Installer wants to make changes. Type your password for this purpose"- I type my password for Adobe ID (creative cloud), but it will not accept it. who should I go for help with this query?

    Dialog box that says ' Creative Cloud Installer wants to make changes. Type your password for this purpose"- I type my password for Adobe ID (creative cloud), but it will not accept it. who should I go for help with this query?

    It does not ask the cloud your computer admin password password!

  • Why between date is not return data for this query?

    Hello
    I have a table with this structure and I write this query to retrieve a few lines based on certain conditions, but this query returns no data. Can you please tell why?
    ID     DT
    
    003     11/8/2011
    002     10/8/2011
    001     9/8/2011
    And the execution of the query:
    SELECT * FROM TABLE_NAME WHERE DT BETWEEN TO_DATE('08/08/2011','dd/mm/yyyy') AND TO_DATE('12/08/2011','dd/mm/yyyy');
    Published by: starting August 13, 2011 07:10

    >

    >

    But what is the problem with that, why this date does not match when I'm providing the date format?

    What part don't you understand? You have not used TO_DATE when inserting data and default date format is dd/mm/yyyy, right? Same default date format is used if you are running:

    SELECT * FROM TABLE_NAME

    Original of your post States select returns above:

    ID     DT
    
    003     11/8/2011
    002     10/8/2011
    001     9/8/2011
    

    So the dates that you inserted are November 8, 2011, October 8, 2011-September 8, 2011. TO_DATE('08/08/2011','dd/mm/yyyy') is now August 8, 2011 and TO_DATE('12/08/2011','dd/mm/yyyy') is August 12, 2011. Then of course:

    SELECT * FROM TABLE_NAME WHERE DT BETWEEN TO_DATE('08/08/2011','dd/mm/yyyy') AND TO_DATE('12/08/2011','dd/mm/yyyy').

    will return all the lines. Bottome line - never write code that uses the implicit conversions date since your code becomes dependent on the NLS client settings and maybe working for a client and fail or produce erroneous results for other customers.

    SY.

  • This query not work?

    I am writing a query as part of my project to do-

    I have a contact in the table that stores phone numbers of all employees in a phone of the column. This column is not a unique constraint, so duplicate values are in there too. Now, I'm checking these duplicate values. This query not work?
    Select the phone of the contact by phone group after having count (*) > 1?

    I know that I can always publish this and test, but I don't have my tables created yet. I'm still writing my code.
    Help, please

    user6440749 wrote:

    I know that I can always publish this and test, but I don't have my tables created yet. I'm still writing my code.

    create table contact (phone number);
    insert into phone values (1234567890);
    insert into phone values (1234567891);
    insert into phone values (1234567892);
    insert into phone values (1234567893);
    insert into phone values (1234567894);
    insert into phone values (1234567892);
    

    And then run your selection. It's probably faster than writing this post and ask someone else to do.

  • How to optimize this query?

    Hello

    I have a query like this:

    Merge into the table st1

    using (select * from (select pk, value, diff_value, m_date, row_number () over (PARTITION pk ORDER BY diff_value) rnk)

    from (select distinct / * + Full (t1) full (t2) * / t1.pk, t2.m_date)

    , Case when (t1.m_date = t2.m_date) then "CORRESPONDENCE".

    When (t2.m_date BETWEEN t1.m_date-1 and t1.m_date + 1) then ' MATCHED WITH +/-1gg.

    When (t2.m_date BETWEEN t1.m_date-2 and t1.m_date + 2) then "MATCHED WITH +/-2 days.

    else "

    end value_match

    Case when (t1.m_date = t2.m_date) then 0

    Where (t2.m_date BETWEEN t1.m_date + 1 and t1.m_date - 1) then 1

    Where (t2.m_date BETWEEN t1.m_date + 1 and t1.m_date - 1) then 2

    else "

    end diff_value

    of table t2, t1 table

    where t1.value is null

    and t1.id = t2.id)

    where value_match is not null)

    where rnk = 1) s

    on (st1.pk = s.pk)

    WHEN MATCHED THEN

    Update set st1.value = s.value_match, st1.diff_value = s.diff_value, st1.up_date = s.m_date

    where st1.value is null.

    Explain the plan:

    EXPLAIN_PLAN1.jpg

    Table1 a record 3Million and table 2 has 1 million records.

    I used gather stats before you run this query and 'Full' trick, even in this case, he is running for 45 minutes.

    Please suggest the best solution to optimize this query.

    Thanks in advance.

    Remove the tips.

    No need for the separate.

    Get the diff by ceil (abs(t2.m_date-t1.m_date)) and the filter for that where value_diff<>

    Assing the statement ".. MATCHED" lately in the update clause.

    Maybe give exactly to your needs with a small example may be the query may be getting more simplified or not what you want it to do.

  • error "Ibsta" no was not declared in this scope

    I have a "error: 'Ibsta' was not declared in this scope."

    I try to program with C++ and GPIB test equipments, but so far, I have this problem.

    I'm sorry, but my knowledge of C++ is very limited because I took a module on it for about 4 months in College and now I have to rectify emergency for my project. Any help would be much apprciated, I tried searching the forums, but I still have to find an answer. I think it has something to do with my linker. BTW, I use Code blocks to compile program, so it may be different from other IDEs posted here such as Microsoft Visual C++, Borland, Dev C++.

    The program that I write to you is as follows:

    #include
    #include "ni488.h".
    #include
    #include
    #include "Decl. - 32.h"
    #include

    using namespace std;

    void GpibError (const char * msg); / * Function to Error statement * /.

    Device int = 0; / * Peripheral device descriptor * /.
    int BoardIndex = 0; / * Interface index (GPIB0 = 0, GPIB1 = 1, etc..) * /.

    int main() {}
    int PrimaryAddress = 28; / * Main unit address * /.
    int SecondaryAddress = 0; / * Secondary unit address * /.
    char Buffer [101]; / * Read buffer * /.

    /*****************************************************************************
    * Boot - made only once at the beginning of your application.
    *****************************************************************************/

    Device = ibdev (/ * create a device descriptor pointer * /)
    BoardIndex, / * Board Index (GPIB0 = 0, GPIB1 = 1,...) * /.
    PrimaryAddress, / * address of the primary device * /.
    SecondaryAddress, / * peripheral secondary address * /.
    T10s, / * delay (T10s = 10 seconds) option * /.
    1, / * line EOI assert at the end of writing * /.
    (0); / * Mode of termination EOS * /.
    If (Ibsta() & ERR) {/ * find GPIB error * /}
    GpibError ("ibdev Error");
    }

    ibclr (Device); / * System * /.
    If {(Ibsta() & ERR)
    GpibError ("ibclr Error");
    }

    /*****************************************************************************
    * Body - writing the majority of your GPIB application code here.
    *****************************************************************************/

    ibwrt (device, "* IDN?", 5 "); / * Send the command ID of the query * /.
    If {(Ibsta() & ERR)
    GpibError ("ibwrt Error");
    }

    Bird (device, buffer, 100); / * Read up to 100 bytes of the device * /.
    If {(Ibsta() & ERR)
    GpibError ("Bird error");
    }

    Buffer [Ibcnt ()] = '\0 '; / * Null terminate the string ASCII * /.

    printf ("%s\n", buffer); / * Print the device identification * /.

    /*****************************************************************************
    * UN-initialize - done only once at the end of your application.
    *****************************************************************************/

    ibonl (device, 0); / * Turn off the line * /.
    If {(Ibsta() & ERR)
    GpibError ("ibonl Error");
    }

    }

    /*****************************************************************************
    * Function GPIBERROR
    * This function will warn you that a function of NOR-488 failed by
    * a print error message. The State IBSTA variable will also be
    * printed in hexadecimal with the senses mnemonic of the forest
    * position. The State IBERR variable will be printed in decimal form
    * with the mnemonic significance of the decimal value. The status
    * Variable IBCNT will be printed in decimal form.
    *
    * The NOR-488 IBONL function is called to turn off the equipment and
    * software.
    *
    OUTPUT Comptrollership will end this program.
    *****************************************************************************/
    void GpibError (const char * msg) {}

    printf ("%s\n", msg);

    printf ("Ibsta () = 0 x %x<",>
    If (Ibsta() & ERR) printf ("ERR");
    If (Ibsta() & TIMO) printf ("TIMO");
    If (Ibsta() & END) printf ("END");
    If (Ibsta() & SRQI) printf ("SRQI");
    If (Ibsta() & RQS) printf ("QR");
    If (Ibsta() & CMPL) printf ("CMPL");
    If (Ibsta() & LOK) printf ("LOK");
    If (Ibsta() & REM) printf ("REM");
    If (Ibsta() & CIC) printf ("CIC");
    If (Ibsta() & ATN) printf ("ATN");
    If (Ibsta() & TAC) printf ("TAC");
    If (Ibsta() & MFP) printf ("LAKES");
    If (Ibsta() & CDI) printf ("CDI");
    If (Ibsta() & DCAS) printf ("DCAS");
    printf ("" > \n ");

    printf ("Iberr() = %d", Iberr() ");
    If (Iberr() == EDVR) printf ("EDVR \n");
    If (Iberr() == ECIC) printf ("in ECIC \n");
    If (Iberr() == ENOL) printf ("ENOL \n");
    If (Iberr() == EADR) printf ("EADR

    \n");

    If (Iberr() == HELLO) printf ("the GRAE \n");
    If (Iberr() == ESAC) printf ("ALD \n");
    If (Iberr() == EABO) printf ("EABO \n");
    If (Iberr() == ENEB) printf ("ENEB \n");
    If (Iberr() == PAES) printf ("PAES \n");
    If (Iberr() == ECAP) printf ("ECAP \n");
    If (Iberr() == EFSO) printf ("EFSO \n");
    If (Iberr() == USBE) printf ("USBE \n");
    If (Iberr() == ESTB) printf ("ESTB \n");
    If (Iberr() == ESRQ) printf ("ESRQ \n");
    If (Iberr() == XTAB) printf ("Established\n");
    If (Iberr() == ELCK) printf ("ELCK \n");
    If (Iberr() == MART) printf ("MART \n");
    If (Iberr() == EHDL) printf ("EHDL \n");
    If (Iberr() == EWIP) printf ("EWIP \n");
    If (Iberr() == ERST) printf ("ERST \n");
    If (Iberr() == EPWR) printf ("EPWR \n");

    printf ("Ibcnt () = %u\n", Ibcnt() ");
    printf ("\n");

    / * Call the ibonl to get the device and interface offline * /.
    ibonl (device, 0);

    "exit" (1);
    }

    The program I had is a sample I found the Instrument National software called GPIB Explorer.


  • Receive the error message"the update is not applicable to this computer" when you run a Windows Update

    Original title: XP mode on a lenovo w t520 / teacher of WIN 7 and intel VT?

    new computer, no additional software isn't installed, followed all the instructions from Microsoft in order. After having successfully performed the WindowsXPMode_es - are .exe, I try to run the Windows6. 1 - KB958559 - x 64 - RefreshPkg.msu and I get the message: "update is not appliably to this computer" and the exe in XP mode is not located anywhere on the drive.

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums. You can follow the link to your question:

    http://social.technet.Microsoft.com/forums/en/itproxpsp/threads

    Hope this information helps.

  • My error says "modification is not allowed because this selection is locked", how to unlock this or what I can do to fix my windows.

    When I try to go into my Windows Word and type something, it won't allow me.  He told me that this modification is not allowed because this selection is locked.  How can I fix it.  Miss me a lot of homework, so for this reason.  It allows me to remove the program from the Control Panel Add/Remove program also.

    -You can publish the same query in the office community
    http://www.Microsoft.com/Office/Community/en-us/FlyoutOverview.mspx

  • MS Html Help is not installed on this PC

    I have been using a trading on XP very good software, but since installing this software on my Windows Vista Home Premium (Svc Pk 2), I get the dreaded "MS Html Help is not installed on this PC" whenever I am trying to view the 'Help' file from the software owner menu.

    One of the messages on this forum (http://social.answers.microsoft.com/Forums/en-US/vistaprograms/thread/781b8c60-41cf-482f-bcd9-d20455f9b190) said a solution "the solution is to change the call to be directly to the Windows API htmlHelp." If this is the case how can I do to run the software to do this.

    Appreciate your help guys :-)

    Hi Chris,

    Do you have what program of commercial software installed?

    You can follow the steps mentioned in the link below to install HTML (Hypertext Markup Language) help that may be required to open a help file with your program.

    Installation of HTML help

    http://msdn.Microsoft.com/en-us/library/aa733988 (VS.60) .aspx

    For more specialist on this question help, you can post your query on the TechNet Forum

    TechNet Forum

    http://social.technet.Microsoft.com/forums/en/w7itproappcompat/threads

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

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

  • Microsoft enhanced Point and print compatibility driver printer driver is not installed on this computer

    We are running Windows 7 Enterprise 64-bit (using VMware View 6.1) virtual work stations and the connection of users to a printer Xerox 4 Type driver/file being hosted on a Windows R2 server in 2012. The driver on the server is listed as "Xerox WorkCentre 7970 V4 PCL6" and when the user of Windows 7 connects the driver appears as "Microsoft enhanced driver compatibility point and print. In the "Print Management" client Win7, it appears as the 6.3.9600.17415 version

    The Printer works fine during their Windows session, they disconnect you and when they connect in the print queue is still there but when you right click and go to "Printer properties", he throws the following error

    "The printer driver ' improved point and print compatibility Microsoft driver" is not installed on this computer. " Some printer properties will be unavailable, unless you install the printer driver. You want to install the driver now? »

    Deleting the queue and then add it again resolves the problem for Windows session, you're.

    Note: we use Persona management of VMware to save data from the user profile of the disconnections from the virtual offices are non-persistent. I've been able to reproduce this in Windows 7 using a virtual office, I can't reproduce it on my physical Windows 7 machine.

    We get around this by using Group Policy and a vbs script to delete the queue on logoff, then another script to add back on logon, but it's just a band-aid.

    In addition, a Type 3 driver works fine in all of disconnections but we need the Type 4 driver in this case.

    Hello Brian,.

    Thank you for visiting Microsoft Community and we provide a detailed description of the issue.

    I suggest you to send your request in the TechNet forums to get the problem resolved.

    Please visit the link below to send your query in the TechNet forums:

    https://social.technet.Microsoft.com/forums/en-us/home?category=WindowsServer

    Hope this information is useful. Please come back to write to us if you need more help, we will be happy to help you.

  • Error: "this meeting uses computer audio (VoIP), computer audio is not available with this console, which is based on the Web." To get the audio from the computer, please install the Microsoft Office Live Meeting client. »

    Hello

    I have a problem with Live meeting 2007. I'm organizing a live meeting with people from different countries. Some of them cannot hear anything and can not use the microphone. They get this kind of error:

    "This meeting uses computer audio (VoIP), computer audio is not available with this console, which is based on the Web." To get the audio from the computer, please install the Microsoft Office Live Meeting client. »

    I tried to look for a solution, but I did not understand what Live Meeting I need to download.

    Can you help me?

    Thank you.

    Original title: Live Meeting 2007

    Hi Alex,

    Thanks for posting your query in Microsoft Community.

    I understand your concern. In this case, I suggest you refer to the Microsoft TechNet article following which sets out the series of frequently asked questions related to Live Meeting 2007 and check if the solutions are useful.

    FAQ: Live Meeting related topics media

    Hope this information is useful. Let us know if you need more help, we will be happy to help you.

  • can not connect because the logon method, you use is not allowed on this computer.

    I have a new computer that is joined to the domain, but in trying to have a user login, I get the following error:

    can not connect because the logon method, you use is not allowed on this computer.

    The only way for him to connect is to change its parameters from the user to the administrator. I tried power users and other options and did not work.

    is there any solution for this?

    Hi Snidera,

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums.

    http://social.technet.Microsoft.com/forums/en-us/category/w7itpro

    It will be useful.

Maybe you are looking for