Historical and transaction data in the same tables creates perf problems

Our Oracle based application is slow partly due to the fact that historical data are kept in the same table as transactional data. For example records about deceased patients, patients treated 5 years ago...etc, are kept in the one and only one patient table, which is needed to run the daily process of the hospital. So gradually all our major tables PATIENTS, CHARTS, NAMES, APPOINTMENTS have grown very large and since most of our SQL join all these tables at the same time, then all screens and reports run very slowly. I have introduced the idea that we should split all these tables in two: historical PATIENTS data, and CURRENT PATIENTS data...the same with all the others. A nice system would first search in the smaller transactional tables, which would run faster being smaller, and if no data found, then fallback to the historical tables. But this would require programming. From what I have read mateialized view could solve part of our problem. We could have views containing for example only one year worth of the data, and I guess any changes could be later replicated in the base table. What I dont know is what to do if we cannot find the patient in the matealized views ? Do I need to fallback to another SQL which will search in the initial base tables ? Anyway we can implement this without programming ? Tx.

Appointment table: 207,470
Visit table: 5,890,920
Patient table: 2,993,129
Chart table: 2,864,069
Patient names table: 3,938,118
SELECT
    APPOI_OR_VISIT,
    VISIT_SEQ,
    PAT_SEQ,
    INST_CODE,
    INST_CODE_DISPL,
    INST_DESC,
    CLINIC_CODE,
    CLINIC_CODE_DISPL,
    CLINIC_DESC,
    SPEC_CODE,
    SPEC_CODE_DISPL,
    SPEC_DESC,
    VISIT_DATE,
    VISIT_TIME,
    VISIT_TIME_ARRIVAL,
    APPTYPE_CODE,
    SESSION_DOM_MODE,
    PRESTYPE_CODE,
    PRESTYPE_DOM_TYPE,
    DIA_CODE,
    VISIT_TIME_START_RESP,
    VISIT_TIME_DISCHARGE,
    APPOI_NB_DURATION,
    VISIT_TX_REASON,
    VISIT_TX_COMMENT,
    EXTDOC_CODE,
    VISIT_PN_REFPHYS_NAME,
    PATYPE_CODE,
    PAYRESP_CODE,
    VISIT_IND_GROUP,
    VISIT_PCODE,
    VISIT_IND_COMPLETE,
    VISIT_IND_ADMISSION,
    VISIT_IND_CONFIDENTIALITY,
    VISIT_DATE_ACCIDENT,
    APPOI_SEQ,
    BILLING_CODE,
    VISIT_TX_DIAGNOSIS,
    CST_CODE_1,
    CST_CODE_2,
    CST_CODE_3,
    APPOI_DH_CRE,
    APPOI_CODE_CRE_USER,
    APPOI_DH_MOD,
    APPOI_CODE_MOD_USER,
    VISIT_CODE_CRE_USER,
    VISIT_DH_CRE,
    VISIT_UPDATED_COUNT,
    VISIT_CODE_MOD_USER,
    VISIT_DH_MOD,
    APPOI_PAYRESP_CODE,
    APPOI_DT_ACCIDENT,
    PATIENT_LAST_NAME,
    PATIENT_FIRST_NAME,
    PATIENT_CONFIDENTIALITY,
    PATIENT_CHART_EXT,
    TO_NUMBER(SUBSTR(PATIENT_CHART_EXT, 1, INSTR(PATIENT_CHART_EXT, '|')-1)) AS PATIENT_CHART_NO,
    PAT_IND_SPECIAL_RISK
FROM
    SELECT
        'VISIT'              AS APPOI_OR_VISIT,
        VISIT.VISIT_SEQ,
        VISIT.PAT_SEQ,
        INSTITUTION.INST_CODE,
        INSTITUTION.INST_CODE_DISPL,
        INSTITUTION.INST_DESC,
        CLINIC.CLINIC_CODE,
        CLINIC.CLINIC_CODE_DISPL,
        CLINIC.CLINIC_DESC,
        SPECIALTY.SPEC_CODE,
        SPECIALTY.SPEC_CODE_DISPL,
        SPECIALTY.SPEC_DESC,
        VISIT.VISIT_DATE,
        VISIT.VISIT_TIME,
        VISIT.VISIT_TIME_ARRIVAL,
        VISIT.APPTYPE_CODE,
        VISIT.SESSION_DOM_MODE,
        VISIT.PRESTYPE_CODE,
        VISIT.PRESTYPE_DOM_TYPE,
        VISIT.DIA_CODE,
        VISIT.VISIT_TIME_START_RESP,
        VISIT.VISIT_TIME_DISCHARGE,
        VISIT.APPOI_NB_DURATION,
        VISIT.VISIT_TX_REASON,
        VISIT.VISIT_TX_COMMENT,
        VISIT.EXTDOC_CODE,
        VISIT.VISIT_PN_REFPHYS_NAME,
        VISIT.PATYPE_CODE,
        VISIT.PAYRESP_CODE,
        VISIT.VISIT_IND_GROUP,
        VISIT.VISIT_PCODE,
        VISIT.VISIT_IND_COMPLETE,
        VISIT.VISIT_IND_ADMISSION,
        VISIT.VISIT_IND_CONFIDENTIALITY,
        VISIT.VISIT_DATE_ACCIDENT,
        VISIT.APPOI_SEQ,
        VISIT.BILLING_CODE,
        VISIT.VISIT_TX_DIAGNOSIS,
        VISIT.CST_CODE_1,
        VISIT.CST_CODE_2,
        VISIT.CST_CODE_3,
        VISIT.APPOI_DH_CRE,
        VISIT.APPOI_CODE_CRE_USER,
        VISIT.APPOI_DH_MOD,
        VISIT.APPOI_CODE_MOD_USER,
        VISIT.VISIT_CODE_CRE_USER,
        VISIT.VISIT_DH_CRE,
        VISIT.VISIT_UPDATED_COUNT,
        VISIT.VISIT_CODE_MOD_USER,
        VISIT.VISIT_DH_MOD,
        NULL AS APPOI_PAYRESP_CODE,
        TO_DATE(NULL) AS APPOI_DT_ACCIDENT,
        NAME.NAM_PN_NAM AS PATIENT_LAST_NAME,
        NAME.NAM_PN_FNAM AS PATIENT_FIRST_NAME,
        CONFIDENTIALITY.CONF_DESC AS PATIENT_CONFIDENTIALITY,
        PI_SECURITY.F_GET_CHART_NUMBER_SCAN_CODE(VISIT.PAT_SEQ, 103 /*:pChartInstitutionID*/, 0) AS PATIENT_CHART_EXT,
        PATIENT.PAT_IND_SPECIAL_RISK
    FROM
               AS_T_VISITS        VISIT,
               CT_R_INSTITUTIONS  INSTITUTION,
               AS_T_CLINICS       CLINIC,
               CT_R_SPECIALITIES  SPECIALTY,
               PI_T_NAMES         NAME,
               PI_T_PATIENTS      PATIENT,
               PI_R_CONF_LEVELS   CONFIDENTIALITY
    WHERE
        VISIT_DATE >= TO_DATE('2004-04-01', 'YYYY-MM-DD') /*:P_VISIT_DATE_FROM*/ AND
        VISIT_DATE <= TO_DATE('2004-04-02', 'YYYY-MM-DD') /*::P_VISIT_DATE_TO*/ AND
        CLINIC.CLINIC_CODE = VISIT.CLINIC_CODE AND
        SPECIALTY.SPEC_CODE = CLINIC.SPEC_CODE AND
        INSTITUTION.INST_CODE(+) = VISIT.INST_CODE AND
        NAME.PAT_SEQ = VISIT.PAT_SEQ AND
        NAME.NAMTYP_CODE = 1 AND
        PATIENT.PAT_SEQ = VISIT.PAT_SEQ AND
        CONFIDENTIALITY.CONF_CODE (+) = PATIENT.CONF_CODE
    UNION
    SELECT
        'APPOI'                                                                                                                                                                                                        AS APPOI_OR_VISIT,
        0                                                                                                                                                                                                                            AS VISIT_SEQ,
        NVL(APPOINTMENT_GROUP.PAT_SEQ, APPOINTMENT.PAT_SEQ) AS PAT_SEQ,
        INSTITUTION.INST_CODE,
        INSTITUTION.INST_CODE_DISPL,
        INSTITUTION.INST_DESC,
        CLINIC.CLINIC_CODE,
        CLINIC.CLINIC_CODE_DISPL,
        CLINIC.CLINIC_DESC,
        SPECIALTY.SPEC_CODE,
        SPECIALTY.SPEC_CODE_DISPL,
        SPECIALTY.SPEC_DESC,
        APPOINTMENT.SESSION_DATE                                                                                                                                                                AS VISIT_DATE,
        APPOINTMENT.APPOI_TIME                                                                                                                                                                     AS VISIT_TIME,
        ''                                                                                                                                                                                                                  AS VISIT_TIME_ARRIVAL,
        APPOINTMENT.APPTYPE_CODE,
        APPOINTMENT.SESSION_DOM_MODE,
        0                                                                                                                                                                                                                            AS PRESTYPE_CODE,
        ''                                                                                                                                                                                                                  AS PRESTYPE_DOM_TYPE,
        0                                                                                                                                                                                                                            AS DIA_CODE,
        ''                                                                                                                                                                                                                  AS VISIT_TIME_START_RESP,
        ''                                                                                                                                                                                                                  AS VISIT_TIME_DISCHARGE,
        APPOINTMENT.APPOI_NB_DURATION,
        APPOINTMENT.APPOI_TX_REASON                                                                                                                                                           AS VISIT_TX_REASON,
        APPOINTMENT.APPOI_TX_COMMENT                                                                                                                                                      AS VISIT_TX_COMMENT,
        APPOINTMENT.EXTDOC_CODE,
        APPOINTMENT.APPOI_PN_REFPHYS_NAME                                                                                                                                            AS VISIT_PN_REFPHYS_NAME,
        APPOINTMENT_TYPE.PATYPE_CODE  AS PATYPE_CODE,
        0                                                                                                                                                                                                                            AS PAYRESP_CODE,
        DECODE(APPOINTMENT_GROUP.PAT_SEQ,NULL,0,1)                                                                                                                   AS VISIT_IND_GROUP,
        ''                                                                                                                                                                                                                  AS VISIT_PCODE,
        0                                                                                                                                                                                                                            AS VISIT_IND_COMPLETE,
        0                                                                                                                                                                                                                            AS VISIT_IND_ADMISSION,
        APPOINTMENT.APPOI_IND_CONFIDENTIALITY                                                                                                                                  AS VISIT_IND_CONFIDENTIALITY,
        TO_DATE(NULL)                                                                                                                                                                                          AS VISIT_DATE_ACCIDENT,
        APPOINTMENT.APPOI_SEQ,
        0                                                                                                                                                                                                                            AS BILLING_CODE,
        ''                                                                                                                                                                                                                  AS VISIT_TX_DIAGNOSIS,
        0                                                                                                                                                                                                                            AS CST_CODE_1,
        0                                                                                                                                                                                                                            AS CST_CODE_2,
        0                                                                                                                                                                                                                            AS CST_CODE_3,
        APPOINTMENT.APPOI_DH_CRE                                                                                                                                                                AS APPOI_DH_CRE,
        APPOINTMENT.APPOI_CODE_CRE_USER                                                                                                                                                 AS APPOI_CODE_CRE_USER,
        APPOINTMENT.APPOI_DH_MOD                                                                                                                                                                AS APPOI_DH_MOD,
        APPOINTMENT.APPOI_CODE_MOD_USER                                                                                                                                                 AS APPOI_CODE_MOD_USER,
        ''                                                                                                                                                                                                                  AS VISIT_CODE_CRE_USER,
        SYSDATE                                                                                                                                                                                                             AS VISIT_DH_CRE,
        0                                                                                                                                                                                                                            AS VISIT_UPDATED_COUNT,
        ''                                                                                                                                                                                                                  AS VISIT_CODE_MOD_USER,
        SYSDATE                                                                                                                                                                                                             AS VISIT_DH_MOD,
        PAYRESP_CODE                                                                             AS APPOI_PAYRESP_CODE,
        APPOI_DT_ACCIDENT,
        NAME.NAM_PN_NAM AS PATIENT_LAST_NAME,
        NAME.NAM_PN_FNAM AS PATIENT_FIRST_NAME,
        CONFIDENTIALITY.CONF_DESC AS PATIENT_CONFIDENTIALITY,
                                    PI_SECURITY.F_GET_CHART_NUMBER_SCAN_CODE(APPOINTMENT.PAT_SEQ, 103 /*:pChartInstitutionID*/, 0) AS PATIENT_CHART_EXT,
        PATIENT.PAT_IND_SPECIAL_RISK
    FROM
               AS_T_APPOINTMENTS       APPOINTMENT,
               AS_R_APPOINTMENT_TYPES  APPOINTMENT_TYPE,
               AS_T_CLINICS            CLINIC,
               CT_R_SPECIALITIES       SPECIALTY,
               CT_R_INSTITUTIONS       INSTITUTION,
               AS_T_APPOINTMENT_GROUPS APPOINTMENT_GROUP,
               PI_T_PATIENTS           PATIENT,
               PI_R_CONF_LEVELS        CONFIDENTIALITY,
               PI_T_NAMES              NAME,
               AS_T_APPOINTMENT_SEQ_MAPPING  SEQMAP
    WHERE
        SESSION_DATE >= TO_DATE('2004-04-01', 'YYYY-MM-DD') /*:P_VISIT_DATE_FROM*/ AND
        SESSION_DATE <= TO_DATE('2004-04-02', 'YYYY-MM-DD') /*::P_VISIT_DATE_TO*/ AND
        APPOINTMENT.APPOI_DOM_TYPE IN('A','AR') AND
        CLINIC.CLINIC_CODE = APPOINTMENT.CLINIC_CODE AND
        SPECIALTY.SPEC_CODE = CLINIC.SPEC_CODE AND
        INSTITUTION.INST_CODE(+) = APPOINTMENT.INST_CODE AND
        APPOINTMENT_GROUP.APPOI_SEQ (+) = APPOINTMENT.APPOI_SEQ AND
        APPOINTMENT_TYPE.APPTYPE_CODE (+) = APPOINTMENT.APPTYPE_CODE AND
        NAME.PAT_SEQ = NVL(APPOINTMENT.PAT_SEQ, APPOINTMENT_GROUP.PAT_SEQ) AND
        NAME.NAMTYP_CODE = 1 AND
        PATIENT.PAT_SEQ = NVL(APPOINTMENT.PAT_SEQ, APPOINTMENT_GROUP.PAT_SEQ) AND
        CONFIDENTIALITY.CONF_CODE (+) = PATIENT.CONF_CODE AND
        SEQMAP.APPOI_SEQ (+) = APPOINTMENT.APPOI_SEQ AND
        SEQMAP.APPOI_SEQ IS NULL
ORDER BY
     VISIT_DATE, VISIT_TIME, PATIENT_CHART_NO

Similar Messages

  • How to update a table (CUSTOMER) on a Report Server with the data from the same table (CUSTOMER) from another server Transaction server?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) From another server ex: Transaction server?
    Set up steps so inset, update or delete operation takes place across the servers.
    It would be great if someone please enlighten me in details about this process in MS SQL Server 2008 R2.
    Also please describe would it be different for SQL Server 2012?
    If so, then what are the steps?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) from another server ex: Transaction server?
    Set up steps so that inset, update or delete operation gets done correctly across servers.
    I was not sure about the answer, it would be great if someone please put some light on this and explain in details about this process in MS SQL Server 2008 R2.
    Also it would be very helpful if you please describe would it be different for SQL Server 2012? If so, then what are the steps?

  • Nsert/Update and Add Column at the same Table and at the "same" Time

    Hello,
    I want Insert/Update and Add Column at the same Table and at the "same" Time but in different sessions.
    Example:
    At first the "insert/update" statement:
    Insert into TestTable (Testid,Value) values (1,5105);
    After that the "add" statement:
    Alter table TestTable add TestColumn number;
    - sadly now I get the message: ORA-00054: resource busy and acquire with NOWAIT specified
    "insert/update" statement:
    Insert into TestTable (Testid,Value) values (2,1135);
    After that the execute commit.
    I don't know when the first session set the commit statement so I want that the DB the "Alter Table..." statement execute if it's possible.
    If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.
    Thanks for ideas

    Well I want to walk in the rain without and umbrella and still stay dry, but it ain't gonna happen.
    You can't run a DDL statement against a table with transactions pending. Session 2 has to wait until session commits or rollbacks (or until the session is killed). That's just the way it is.
    This makes sense if you think about it. The data dictionary has to be consistent across all sessions. If session 2 was allowed to change the table structure whilst session 1 has a pending transaction then the database is in an inconsistent state. This is easier to see if you consider the reverse situation - the ALTER TABLE statement run by session 2 does a DROP COLUMN TESTID rather than adding a column: now what should happen to session 1's INSERT statement? You have retrospectively invalidated a statement that was perfectly legal when it was executed.
    If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.Fnord.
    Cheers, APC

  • How to populate data in the same table based on different links/buttons

    Hi
    I'm using jdeveloper 11.1.4. I have a use case in which i need to populate data in the same table based on click of different links.
    Can anyone please suggest how can this be achieved.
    Thanks

    I have a use case in which i need to populate data in the same table based on click of different linksDo you mean that you need to edit existing rows ?
    What format do you have the date in - table / form ?

  • How can I do to acquire and save date in the same time and in the same file when I run continual my VI without interrupti​on.

    I've attached a VI that I am using to acquire amplitude from Spectrum analyzerse. I tried to connect amplitude ouput to the VI Write Characters To File.vi and Write to Spreadsheet File.vi. Unfortunately when I run continual this VI without interruption, labview ask me many time to enter a new file name to save a new value.
    So, How can I do to aquire and save date in the same time and in the same file when I run continual my VI for example during 10 min.
    Thank you in advance.
    Regards,
    Attachments:
    HP8563E_Query_Amplitude.vi ‏37 KB

    Hi,
    Your VI does work perfectly. Unfortunately this not what I want to do. I've made error in my last comment. I am so sorry for this.
    So I explain to you again what I want to do exactly. I want to acquire amplitude along road by my vehicle. I want to use wheel signal coming from vehicle to measure distance along road. Then I acquire 1 amplitude each 60 inches from spectrum analyzer.
    I acquire from PC parallel port a coded wheel signal coming from vehicle (each period of the signal corresponds to 12 Inches). Figure attached shows the numeric signal coming from vehicle, and the corresponding values “120” and “88” that I can read from In Port vi.
    So I want to acquire 1 time amplitude from spectrum analyser each 5
    period of the signal that I am acquiring from parallel port.
    So fist I have to find how can I count the number of period from reading the values “120” and “88” that I am acquiring from In Port (I don’t know the way to count a number of period from reading values “120” and “88”).
    Here is a new algorithm.
    1) i=0 (counter: number of period)
    2) I read value from In Port
    3) If I acquire a period
    i= i+1 (another period)
    4) If i is multiple of 5 (If I read 5 period)
    acquire 1 time amplitude and write to the same
    file this amplitude and the corresponding distance
    Distance = 12*i). Remember each period of signal
    Corresponds to 12 Inches).i has to take these
    values: 5,10,15,20,25,35,40,45,50,55,60............
    5) Back to 2 if not stop.
    Thank you very much for helping me.
    Regards,
    Attachments:
    Acquire_Amplitude_00.vi ‏59 KB
    Figure_Algorithm.doc ‏26 KB

  • File name and Measuremen​t in the same table?

    Hi,
    I have written the following VI that opens up each image file from a folder and measures a certain dimension on the image. It then puts the result of the measurement in a table.
    The table has one column and N rows since I have N images in my folder. How can I modify this VI so that it puts the filename in the same table as well as the measurement?
    I want the table to look like:
    filename1 measurement1
    filename2 measurement2
    and so on.
    Currently, it just shows
    measurement1
    measurement2
    and so on.
    Here is the VI:
    Solved!
    Go to Solution.
    Attachments:
    measurement.vi ‏68 KB

    You can't use the Express Table. As the properties page says, it is for numeric data. You will have to use a little bit of actual LabVIEW to create the table. A table is just a 2D string array. So, convert the numeric to a string, build a 1D string array from the file name and numberic, and use a shift register to build a 2D array. Something like the code below.
    Message Edited by Dennis Knutson on 05-07-2009 01:43 PM
    Attachments:
    Build Table.PNG ‏9 KB

  • Retrieve data from the same table

    i have a table with following fields
    emp_no,name,salary,department,dept_prev,prev_emp_no.
    now i want retrieve emp_no,name,salary,department, from the data base for a perticular employeee number along with dept_prev
    but dept_prev is the prev_emp_no dept_prev
    now iam doing two query like this
    first query to retreive name,salary,department
    select name,salary,department from employee where emp_no = 10
    second to retrieve the dept_prev from the same table but this
    dept_prev must be based on prev_emp_no
    select dept_prev from employee where emp_no in(select prev_emp_no from employee where emp_no =10)
    can any one suggest to combine these two queries in a single sql statements, because all the fieldds are from the same table.
    Thanks

    Would this one solve it?
    SELECT emp.NAME, emp.salary, emp.department,
           prev_emp.dept_prev
      FROM employee emp,
           employee prev_emp
    WHERE emp.emp_no      = 10
       AND prev_emp.emp_no = emp.prev_emp_no;
    not tested
    C.

  • How to read the hierarchy data from the same table using loop in AMDP method

    Hi All,
    We have a requirement to get the top partner from BUT050 table.
    Here the Top parent is nothing but the top most in the hierarchy of the partners from BUT050.
    Example:
    For partner 1234 (BUT050-PARTNER1) there is partner 3523(BUT050-PARTNER2) one level above
    For partner 3523(BUT050-PARTNER1)  there is partner 4544 (BUT050-PARTNER2) last level .
    so in this case for the partner 1234 the Top parent is 4544 .
    I have created AMDP Procedure method to get the top-parnet and below given is the logic implemented in AMDP method.
    Here i have implemented a recursive logic with the WHILE loop to get the top most hierarchy partner from the same table BUT050
    IV_Parent is the input partner and ev_top_parent is the output value.
    AMDP Procedure Method:
        DECLARE lv_date VARCHAR(8) := TO_VARCHAR (current_date, 'YYYYMMDD');
        DECLARE found INT := 1;
              iv_partner1 =  SELECT partner1 FROM but050
                              WHERE partner2 = iv_partner
                              AND reltyp = :iv_hierarchy
                              AND date_to >=  :lv_date
                              AND date_from <= :lv_date;
         WHILE found <> 0  do
           select partner1 into ev_top_parent from :iv_partner1;
                           iv_partner1 =  SELECT partner1 FROM but050
                           WHERE partner2 in ( select partner1 from :iv_partner1 where partner1 is not null)
                           AND reltyp = 'ZBP004'
                           AND date_to >= :lv_date
                           AND date_from <= :lv_date;
           select COUNT ( partner1 ) INTO found FROM :IV_PARTNER1;
        END WHILE;
    This method is working fine, but here it is only taking one single partner and getting the top parent as output.
    Now i would like to convert this mehtod so as to accept n number of partners (not one single partner) as input and should process each partner to get the top parent.
    Could anyone guide me how can i handle the given AMDP method further so as to work some how it is within another loop from other AMDP method.
    Thanks.
    Regards,
    Laxman.P

    Hi
    Go to SE11 and enter the hierarchy table name.
    /BIC/H....(infoobject name)...and execute the table and select table entry and delete all....
    Thanks
    TG

  • Master and Detail records in the same table

    Hi Steve,
    I have master and detail address records in the same table (self-reference). The master addresses are used as templates for detail addresses. Master addresses do not have any masters. Detail addresses have three masters: a master address, a calendar reference and a department. Addresses change from time to time and every department has its own email-account, but they refer to the same master to pre-fill some common values.
    Now I need to edit the master and detail address records on the same web page simultaneously.
    My question is: Can I implement a Master-View and Detail-View which refer to the same Entity-Object? Or should I implement a second Entity-Object? Or can it be done in a single Master-Detail-View?
    Thanks a lot.
    Kai.

    At a high level, wouldn't this be similar to an Emp entity based on the familiar EMP table that has an association from Emp to itself for the Emp.Mgr attribute?
    You can definitely build a view object that references two entity usages of the same entity like this to show, say, an employee's ENAME and at the same time their manager's ENAME.
    If there are multiple details for a given master, you can also do that with separate VO's both based on the same entity, sure. Again, just like a VO that shows a manager, and a view-linked VO of all the employees that report to him/her.

  • Want to select individual data as well as aggregate data from the same table

    want to select a, b  from tab1  also need to find in the same table  tab1 need to do sum(b) group by a

    SELECT a,b,0 AS Ord
    FROM tab1
    UNION ALL
    SELECT a,SUM(b),1
    FROM tab1
    GROUP BY a
    ORDER BY a,Ord
    assuming SQL Compact
    If its SQL Server then we have much simpler methods
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Multiple language data in the same table and indexes

    We have 8.1.5 database with
    NLS_LANGUAGE=ENGLISH and NLS_TERRITORY=UNITED KINGDOM set at the database level. We also set the NLS_LANG appropriately when we index the data. We also use the preference setting BASE_LETTER=YES when indexing.
    Our tables contain book titles which is what we index using interMedia. Being an online book store, this table may contain titles in English (most of the titles are in English being UK) and some titles in French. Please note the French language has accents and diacritics. Normally in a French database with NLS parameters set correctly and BASE_LETTER=YES, if we search for a title with accent / diacritic it will return the record correctly and match the rows with or without the accents (e.g. searching for video will return both vidio (not the accent on e) and video). However, with the UK settings the accents are not ignored during indexing and it only returns the records that exactly match the search word (e.g. searching for video returns only video and searching for vidio returns only vidio (note the accents on e in the last two videos)).
    Question: Is there any way to appropriately index multiple language specific titles in the same database? If yes, how? Is it possible at all? Suggestions, ideas are welcome.
    null

    Similar request; if there are several different languages used in a database, but a search word can be typed in by anyone and not necessarily in the default language, I still want to be able to pick up all the records (including text in blobs) in any language where my search word = the equivelant word in the other languages; eg. searching on "tree", the search would bring back a document that contained "l'arbre". I then want to set the default language, and allow the user to select a "search in these languages" option to expand the search from the default "tree" to all languages in the database.
    I know about the multi_Lexer but does it extend functionality to this level?

  • Query - Get data from the same table and field two times on a single line

    I have prepared a query showing the bill of material. At each line each component will be a new line and I want to have the description of the material at the top (the master material composed of the component ones) and also the description of the component materials on the same line. This means that I should be able to use MAKT table 2 times on a single line of the query. I have used the query tool with SQ01 and SQ02 tcodes. How can I get the the description of the material at the top and also the description of the component material on a single line?
    Thanks in advance for the answers.

    Yasar,
    Any time you wish to use a table twice in an SQ01 query, you have to create an alias.
    SQ02 > select the infoset, 'change' > go to Join definitions.
    Select 'Alias' button.  Create. Select your table name (such as MAKT) and define an alias, such as 'COMP_MAKT' for component descriptions.
    Now you can insert the Alias table into your infoset just like it was a regular table, and use standard join method to join COMP_MAKT to your component material number.
    Best regards,
    DB49

  • Comparing SQL data in the same table for two different dates

    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Hello,
    We have a batch scheduling tool that automatically runs Oracle jobs and when it runs the jobs it stores a record from the instance in a table. I am trying to write a query that pulls up all of the jobs that ran today and compares them with what ran on the same day last week to find out what jobs didnt run today. So far I have the below but I can't get it to return anything. I am using Toad for this
    select *
    from xxcar_abat_instances
    where trunc(to_date(start_datetime)) = trunc(sysdate-7)
      and completion_status = 'Success'
    AND NOT EXISTS
      (select script_name
        from xxcar_abat_instances
       where trunc(to_date(start_datetime)) = trunc(sysdate)
         and completion_status = 'Success')Thank you

    Hi,
    964188 wrote:
    It is a date
    Such as
    10/31/2012 11:55:03 PMThen, as Hoek says, you don't want TO_DATE. For example:
    WHERE   TRUNC (start_datetime) = TRUNC (SYSDATE - 7) or the more efficient
    WHERE   start_datetime >= TRUNC (SYSDATE - 7)
    AND     start_datetime <  TRUNC (SYSDATE - 6)Also, it doesn't look like the EXISTS sub-query is corelated to the main query. That's almost certainly a mistake.
    If you're still having trouble, post your revised query, a little sample data (CREATE TABLE and INSERT statements). Point out where that query is givimg the wrong results, and explain how to get te right results.
    See the forum FAQ {message:id=9360002}

  • Average time between diferrent dates in the same table

    I am having a big problem trying to get this sentence for my report the thing is that I have a table name ca_parking
    ca_parking (
    id_parking number,
    date_in date,
    date_out date,
    id_truck number,
    id_user_rec number,
    date_rec date);
    where date_in and date_out are the day and time where truck get in and out of the building, id_parking is the pk of the table, id_truck is the fk from table ca_truck, id_user_rec is the user who enters the data on the system, anda date_rec is the date when the record is inserted.The company asked for an average of time spent by the trucks inside the parking lots so i need to use the date_in from one record less the date out from the next record of the same truck
    id_parking date_in date_out id_truck id_user_rec date_rec
    451794     03/07/2012 8:50:00     02/07/2012 20:00:00     36937     MFUERTE     02/07/2012 20:08:16
    452580     05/07/2012 7:00:00     04/07/2012 20:15:00     36937     VCONTRERAS 04/07/2012 13:56:33
    451591     02/07/2012 18:00:00     02/07/2012 13:00:00     47393     OVILLACIS     02/07/2012 13:39:40
    451824     03/07/2012 17:00:00     03/07/2012 7:00:00     47393     OVILLACIS     03/07/2012 7:06:37
    453160     05/07/2012 17:00:00     05/07/2012 14:50:00     47393     WALEMA     05/07/2012 14:57:51
    So i need to do something like this
    select avg(ca_parking.date_in - ca_parking.date_out), ca_trucks.trcuk_alias from ca_parking, ca_trucks where ca_parking.id_truck = ca_trucks.id_truck
    group by ca_trucks.trcuk_alias
    but i get only trash
    I need it to do this for truck 36937 { (04/07/2012 20:15:00 - 03/07/2012 8:50:00) + (sysdate-05/07/2012 7:00:00)}/2 = 4.37
    and fro truck 47393 { (03/07/2012 7:00:00 -  02/07/2012 18:00:00) + (05/07/2012 14:50:00 - 03/07/2012 17:00:00) + (sysdate - 05/07/2012 17:00:00)}/2 = 4.65
    how can i get the following date_out less the previews date_in

    I am having a big problem trying to get this sentence for my report the thing is that I have a table name ca_parking
    ca_parking (
    id_parking number,
    date_in date,
    date_out date,
    id_truck number,
    id_user_rec number,
    date_rec date);
    where date_in and date_out are the day and time where truck get in and out of the building, id_parking is the pk of the table, id_truck is the fk from table ca_truck, id_user_rec is the user who enters the data on the system, anda date_rec is the date when the record is inserted.The company asked for an average of time spent by the trucks inside the parking lots so i need to use the date_in from one record less the date out from the next record of the same truck
    id_parking date_in date_out id_truck id_user_rec date_rec
    451794     03/07/2012 8:50:00     02/07/2012 20:00:00     36937     MFUERTE     02/07/2012 20:08:16
    452580     05/07/2012 7:00:00     04/07/2012 20:15:00     36937     VCONTRERAS 04/07/2012 13:56:33
    451591     02/07/2012 18:00:00     02/07/2012 13:00:00     47393     OVILLACIS     02/07/2012 13:39:40
    451824     03/07/2012 17:00:00     03/07/2012 7:00:00     47393     OVILLACIS     03/07/2012 7:06:37
    453160     05/07/2012 17:00:00     05/07/2012 14:50:00     47393     WALEMA     05/07/2012 14:57:51
    So i need to do something like this
    select avg(ca_parking.date_in - ca_parking.date_out), ca_trucks.trcuk_alias from ca_parking, ca_trucks where ca_parking.id_truck = ca_trucks.id_truck
    group by ca_trucks.trcuk_alias
    but i get only trash
    I need it to do this for truck 36937 { (04/07/2012 20:15:00 - 03/07/2012 8:50:00) + (sysdate-05/07/2012 7:00:00)}/2 = 4.37
    and fro truck 47393 { (03/07/2012 7:00:00 -  02/07/2012 18:00:00) + (05/07/2012 14:50:00 - 03/07/2012 17:00:00) + (sysdate - 05/07/2012 17:00:00)}/2 = 4.65
    how can i get the following date_out less the previews date_in

  • How can I save images and text data to the same file?

    I have been looking at ways to do this for a while. My main VI saves the raw data to a text file which the users then import to Excel and plot. I am trying to simplify this process and have been looking at ways to accomplish this task. I want to be able to save the raw data to a file and then save the Labview graph as well. This will eliminate the tedious task of importing the raw data into Excel and plotting it. I can save the raw data to its own file and I can use the Get Image method for the graph and save it to its own file. I am currently using the .png format. Is there a way of saving both to the same file ie, importing the image into Excel or Word etc. Before I go off doing a science project I wanted to see if anyone else had experience completing this task and had any recommendations. Thanks in advance for any help.

    well ther are a couple of ways. You could use the standard report generation VI's and make a complete report with the image of the graph embedded into the report with the raw data or you could use activeX and control excel thru LV and put the raw data into excel directly and have excel graph the data without any user interaction. I have posted a slew of VI's on the excel board if you do not have the report generation toolkit. If you could tell me which way you want to go I could possibly send you an example.
    For more information and some sample VI's and tool kits, you can go to the excel board
    Joe.
    "NOTHING IS EVER EASY"

Maybe you are looking for

  • Hp 8500 Office Jet Pro never warned ink was low, how to change this?

    We have 2 of these units and prefer to only have the hp printers.  Got this printer setup, it seems verbose in asking to register, please register, you must register, you cant print until you register.  ok fine lets regsiter then!  thats ok youre alr

  • Problems syncing photos from iPhone to iPhoto

    I have an iPhone 4 installed with iOS 5.0.1. I also have a slightly older version of iPhoto (I believe it's one generation behind; whatever that is). Prior to updating my iPhone to either iOS 5 or iOS 5.0.1 (I didn't check between updates) I used to

  • Can't start "Windows Deployment Services" Service

    I have a Windows 2003 Server that has WDS SP1 installed.  The Windows Deployment Services Server Service isn't started and when I try to start it I get a message that says: Windows could not start the Widows Deployment Services Server on Local Comput

  • When to use Higher Performance

    i have a March 2009 MBP 17" and have been experimenting with Higher Performance and Better Battery Life to see when it is an advantage to use the Higher Performance. I cannot detect any difference when I switch and reboot and I have been trying heaps

  • Passed activation day and no broadband!

    I have been led to believe that yesterday the broadband I had orderd would be active, its not!  I odered my phone line on the first   of March and it was installed last week (three months later). I have always been a cable customer and I sort of expe