Lync LcsLog SQL query assistance

I have this SQL query that we used in the past on LCS and OCS which worked fine.  For Lync it's returning the info I want, but it's also returning all kinds of HTML characters.
SQL query
select * from LcsLog.dbo.Messages,LcsLog.dbo.Users where LcsLog.dbo.Users.UserId=Messages.ToId and LcsLog.dbo.Users.UserUri='[email protected]'
Here's what it returns.  As you can see, all this was just me saying "hello".  How can I remove the html?
2011-06-04 14:03:19.057    1    2011-06-04 14:03:19.057    1    5    2    2    1    {\rtf1\ansi\ansicpg1252\fromhtml1 \fbidis \deff0{\fonttbl 
{\f0\fswiss Arial;}  {\f1\fmodern Courier New;}  {\f2\fnil\fcharset2 Symbol;}  {\f3\fmodern\fcharset0 Courier New;}  {\f4\fswiss MS Shell Dlg 2;}}  {\colortbl\red0\green0\blue0;\red0\green0\blue255;\red0\green0\blue0;}  \uc1\pard\plain\deftab360
\f0\fs24   {\*\htmltag0 \par }  {\*\htmltag48 <BODY>}{\*\htmltag64}\htmlrtf {\htmlrtf0   {\*\htmltag148 <FONT color=#000000 size=2 face="MS Shell Dlg 2">}\htmlrtf {\cf2 \fs20 \f4 \htmlrtf0   {\*\htmltag4 \par
}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf}\htmlrtf0    {\*\htmltag96 <DIV dir=ltr>}\htmlrtf {\ltrpar\ltrch\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 \htmlrtf {\cf2 \fs20 \f4 \htmlrtf0
hello\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0    {\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0   {\*\htmltag248 </FONT>}  {\*\htmltag58 </BODY>}}   
0    0    0    NULL    NULL    2011-06-17 20:04:42.227    2    [email protected]    0    0
d

We are a Microsoft ISV and we have spent a great deal of time reviewing and diving into the lcslog.  In order to help many of our larger enterprise customers, we have built an application specifically to help search, view, and share the conversations
in the LCSLog database. 
Of course, you can extract and assemble this content yourself - but you might want to give us a look.  It's possible it that is might save you some time (on the dev front)
We have a free eval and support both Lync 2010 and Lync 2013 - with a pretty great UI, great performance, and some visual drill down.
Might save you some time...
http://www.tryhrauditor.com/
Peyton

Similar Messages

  • SQL Query Assistance Required for Full Outer Join

    Hi,
    Lets say I have two tables, i.e:
    TAB_A (colA1, colA2, colA3, colA4)
    TAB_B (colB1, colB2, colB3, colB4) where colB2 is a FK to colA1
    I am after an SQL query that will cater for both the following two scenarios.
    Scenario 1:
    TAB_A has two rows of data, i.e
    (1, ABC100, 1, WG_A)
    (2, ABC100, 2, WG_B)
    TAB_B has one row of data, i.e
    (1, 1, EMP_222, 4)
    I use the following SQL:
    select a.*, b.*
    from tab_a a FULL OUTER JOIN tab_b b ON (a.colA1 = b.colB2)
    where a.colA2 = 'ABC100'
    This returns two rows:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    2, ABC100, 2, WG_B
    Now, what I actually would like my query to do is actually only return the row where a tab_b record exists, i.e, should only return one record:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    This I can achieve by using a RIGHT OUTER JOIN instead above, but this causes issue with my scenario 2, which is the following set-up
    Scenario 2:
    TAB_A has only one row of data this time, i.e
    (2, ABC100, 2, WG_B)
    TAB_B has no data at all this time
    This returns no rows but I actually now want this single record from tab_a returned.
    I basically require an SQL query that will cater for both the top 2 scenarios, i.e, if a tab_b record exists from the outer join then only return this record along with tab_a data. If a tab_b record doesn't exist, then only return the tab_a record.
    Hope the above makes sense.
    Thanks.

    Is it what you need (not very elegant) ?
    SQL> select * from t_outer;
            ID CODE
             1 100
             2 100
    SQL> select * from t_inner;
    no rows selected
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             1 100
             2 100
    SQL> insert into t_inner values(2);
    1 row created.
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             2 100                 2
    Rgds.

  • UCCX SQL query assistance needed.

    Hello,
    I am working on a SQL query that does a lookup of the calling number and the last four digits entered by the customer.  If I hard code the lastFourGC variable I am able to return a successful result.  If I use $lastFourGC I get the following error.
    $callingNumber  - Is exactly that, the calling number.
    $lastFourGC - Is the last four digits collected from the customer.
    SELECT * FROM GiftCardFulfillment WHERE Phone=$callingNumber and Right (GiftCard16DigitNumber, 4)=$lastFourGC

    Tanner,
    I had tried that with single and double quotes and it didn't work.  I did end up getting it to work by rearranging the order.  I'm not sure why that worked, but this is what the query looks like now and it works.
    SELECT * FROM [leads].[dbo].[GiftCardFulfillment]   
             WHERE Right (GiftCard16DigitNumber, 4)=$lastFourGC and Phone=$callingNumber

  • SQL Query to Join by Comma  - Help an assistance

    Hi,
    Thanks for your help in advance.
    Requirement is as follows.
    Table1
    =======
    Col1 Col2
    ============
    1 John
    2 Jocky
    3 Silk
    Table2
    ========
    Col1 Col2
    =========
    1 John, Marry, Joseph
    2 Silk, David
    3 Jocky, Prem
    I need an sql query where the join condition has to satisfy as follows
    Table1.col2=Table2.Col2 (If any of the col2 in table1 matches with Table2.Col2 i need to return the record).
    How to do this.
    Please guide me on this.

    nazzu wrote:
    Thanks a lot for your response ...
    But if a table1 and table2 had different numbers of rows then ?
    I may be behaving like a fool ... but my requrirement is such a fashion.
    Please help ...
    Thanks again for your help.
    Edited by: nazzu on Mar 14, 2013 8:22 AMHi,
    try to be clear in your requirement. You mentioned in your initial question:
    I need an sql query where the join condition has to satisfy as followsWhat happen if you have different number of rows in table1 and table2?
    Rows from table2 will be returned for any match in table1 if you are using a normal join. However if you have 2 rows in table1 that are matching table2 then that row in table2 will return twice.
    Let me just show you an example:
    WITH table1(col1, col2) AS
       SELECT 1, 'John'  FROM DUAL UNION ALL
       SELECT 2, 'Jocky' FROM DUAL UNION ALL
       SELECT 3, 'Silk'  FROM DUAL UNION ALL
       SELECT 4, 'Marry' FROM DUAL
    , table2(col1, col2) AS
       SELECT 1, 'John, Marry, Joseph'  FROM DUAL UNION ALL
       SELECT 2, 'Silk, David'          FROM DUAL UNION ALL
       SELECT 3, 'Jocky, Prem'          FROM DUAL
    SELECT t2.col1, t2.col2, t1.col2
      FROM table2 t2
           JOIN table1 t1
              ON(INSTR(', '||t2.col2||',', ', '||t1.col2||',')>0);
          COL1 COL2                COL2_1
             1 John, Marry, Joseph John 
             1 John, Marry, Joseph Marry
             2 Silk, David         Silk 
             3 Jocky, Prem         Jocky As you can see the first row from table2 is returned twice because it matches 2 records on table1.
    In case you want to display only rows from table2 which has a match in table1 you can either do a distinct:
    SELECT DISTINCT t2.col1, t2.col2
      FROM table2 t2
           JOIN table1 t1
              ON(INSTR(', '||t2.col2||',', ', '||t1.col2||',')>0);
          COL1 COL2              
             1 John, Marry, Joseph
             2 Silk, David       
             3 Jocky, Prem        or use EXISTS operator:
    SELECT t2.col1, t2.col2
      FROM table2 t2
    WHERE EXISTS (SELECT 1
                     FROM table1 t1
                    WHERE INSTR(', '||t2.col2||',', ', '||t1.col2||',')>0
          COL1 COL2              
             1 John, Marry, Joseph
             2 Silk, David       
             3 Jocky, Prem   Regards.
    Al

  • SQL Query (updateable report) Region - Conditionally Hide and Set Values

    SQL Query (updateable report) Region - Conditionally Hide and Set Values
    Outline of requirement :-
    Master / Detail page with Detail updated on same page using SQL Query (updateable report).
    The detail region has the following source
    SELECT item_id,
           contract_id,
           CASE WHEN hardware_id IS NOT NULL THEN
                   'HA'
                WHEN backup_dev_id IS NOT NULL THEN
                   'BD'
                WHEN hardware_os_id IS NOT NULL THEN
                   'HS'
           END item_type,
           hardware_id,
           backup_dev_id,
           hardware_os_id
    FROM   "#OWNER#".support_items
    WHERE  contract_id = :P26_CONTRACT_IDThe table support_items implements arced relationships and has the following columns
    CREATE TABLE SUPPORT_ITEMS
      ITEM_ID         NUMBER                        NOT NULL,
      CONTRACT_ID     NUMBER                        NOT NULL,
      HARDWARE_ID     NUMBER,
      BACKUP_DEV_ID   NUMBER,
      HARDWARE_OS_ID  NUMBER
    )A check type constaint on support_items ensures that only one of the fk's is present.
          (    hardware_id    IS NOT NULL
           AND backup_dev_id  IS NULL
           AND hardware_os_id IS NULL
    OR    (    hardware_id    IS NULL
           AND backup_dev_id  IS NOT NULL
           AND hardware_os_id IS NULL
    OR    (    hardware_id    IS NULL
           AND backup_dev_id  IS NULL
           AND hardware_os_id IS NOT NULL
          )    Hardware_Id is a FK to Hardware_Assets
    Backup_dev_id is a FK to Backup_Devices
    Hardware_os_id is a FK to Hardware_op_systems
    The Tabular Form Element based on item_type column of SQL query is Displayed As Select List (based on LOV) referencing a named list of values which have the following properties
    Display Value     Return Value
    Hardware Asset    HA
    Backup Device     BD
    Computer System   HSThe Tabular Form Elements for the report attributes for hardware_id, backup_dev_id and hardware_os_id are all Displayed As Select List (Based on LOV).
    What I want to do is only display the Select List for the FK depending on the value of the Select List on Item Type, e.g.
    Item_Type is 'HA' then display Select List for hardware_id, do not display and set to NULL the Select Lists for backup_dev_id and hardware_os_id.
    Item_Type is 'BB' then display Select List for backup_dev_id, do not display and set to NULL the Select Lists for hardware_id and hardware_os_id.
    Item_Type is 'HS' then display Select List for hardware_os_id, do not display and set to NULL the Select Lists backup_dev_id and hardware_id.
    There are properties on elements to conditionally display it but how do we reference the values of the SQL query Updateable region? they are not given a page item name?
    Also on the Tabular For Elements there is an Edit tick against a report item - however when you go to the Column Attributes there is not a property with which you can control the Edit setting.
    What's the best way of implementing this requirement in APEX 3.1?
    Thanks.

    >
    Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your profile with a real handle instead of "user13515136".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I have a multi-row region that displays values and allows entries in a number of fields.Provide exact details of how this has been implemented. (An example on apex.oracle.com is always a good way to do this.)
    I should like the fields to be conditional in that they do not permit entry, but still display, if certain conditions apply (e.g. older rows greyed out). Can this be done? Almost anything can be done, often in multiple ways. Which are appropriate may be dependent on a particular implementation, the skills available to implement it, and the effort you're willing to expend on it. Hence it's necessary to provide full details of what you've done so far...

  • Newbie - help with a SQL query for a bar chart  - Originally posted in APEX

    I originally posted this in the APEX forum but someone there suggested this is more of a SQL question.  Anyone out there who can provide some assistance?
    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESC
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.
    Is this enough info for some assistance? Any help would really be appreciated.
    Thanks,
    Rachel

    Hi, Rachel,
    user10774102 wrote:
    I originally posted this in the APEX forum but someone there suggested this is more of a SQL question.  Anyone out there who can provide some assistance?
    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESCIs there a problem with the code above?
    It's curious that the WHERE clause includes "PROJECT_STATUS='6'", but there is no pivoted column for project_status='6', like there is for '1' through '5'. That's not necessarily a mistake, and it wouldn't raise an error in any case.
    Instead of
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')you could say
    where PROJECT_STATUS  IN ('1', '2', '3', '4', '5', '6')but that probably has nothing to do with your current problem.
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.Is that an Apex error message? Sorry, I don't know anything about Apex.
    If you can't get a more specific error message from Apex, then try debugging this statement in SQL*Plus. When you get it fixed, then you can copy it back into Apex.
    If this is a SQL problem, then you should be able to re-create the problem in pure SQL.
    If you can't re-create the problem in pure SQL, then it's probably an Apex problem, and belongs in the Apex forum, not here.
    I don't see anything obviously wrong with your code, but I can't tell if, for example, you spelled a column name wrong, or if something has the wrong data type
    Is this enough info for some assistance? Any help would really be appreciated.It wiould be better if you posted a completE script that people could run to re-create the problem, and to test their ideas.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle (and any other software, such as Apex) you're using.

  • SQL Query for members of dynamic group - Need to include Name, Path and Type

    Hello,
    I built a custom dynamic group that has all my SQL databases in it using SCOM 2012 SP1.  The group works fine as I can see the Name(ie, Database name), Health State, Path (ie, hostname/instance) and Types (ie; SQL 2005).  Now I'm trying to
    build a custom report based off this same information using a SQL query.   I'm no DBA and could use some help.  So far this is what i have
    use
    select
    SourceObjectDisplayName as
    'Group Name',
    TargetObjectDisplayName,TargetObjectPath
    from RelationshipGenericView
    where isDeleted=0
    AND SourceObjectDisplayName
    like
    'SQL_Databases_All'
    ORDERBY TargetObjectDisplayName
    This gets me the Group Name (which i really don't care about), database name, and hostname/instance. What I am missing is the Health State and most importantly the Type (ie, SQL Server 2005 DB, SQL Server 2008DB).
    If someone could assist me here I would appreciate it. I believe I need to do some type of INNER JOIN but have no idea where the SQL type info lives or the proper structure to use. Thanks
    OperationsManager

    Here's the updated Query for OpsMan 2012 R2:
    To find all members of a given group (change the group name below):
    select SourceObjectDisplayName as 'Group Name', TargetObjectDisplayName as 'Group Members' 
    from RelationshipGenericView 
    where isDeleted=0 
    AND SourceObjectDisplayName = 'Agent Managed Computer
    Group' 
    ORDER BY TargetObjectDisplayName

  • Newbie - need help with a SQL query for a bar chart

    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESC
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.
    Is this enough info for some assistance? Any help would really be appreciated.
    Thanks,
    Rachel

    Hello,
    This is more of an SQL question, rather than specifically APEX-related. It's notable that you say: I'm a new user on APEX with no real SQL knowledgeWhich is fine (we all have to start somewhere, afterall) but it might be worth de-coupling the problem from APEX in the first instance. I'd also strongly recommend either taking a course, reading a book (e.g. http://books.google.co.uk/books?id=r5vbGgz7TFsC&printsec=frontcover&dq=Mastering+Oracle+SQL&hl=en#v=onepage&q=Mastering%20Oracle%20SQL&f=false) or looking for a basic SQL tutorial - it will save you a whole lot of heartache, I promise you. Search the oracle forums for the terms "Basic SQL Tutorial" and you should come up with a bunch of results.
    Given that you've copied your query template from another, I would suggest ensuring that the actual query works first of all. Try running it in either:
    * SQL Editor
    * SQL*Plus
    * an IDE like SQL Developer (available free from the OTN: http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html ) or TOAD or similar.
    You may find there are syntax errors associated with the query - it's difficult to tell without looking at your data model.
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORYNote that your "order by" clause references a field called "PROJECT_ID", which exists in the old query but you've changed other similar references to "PROJECT_STATUS" - is it possible you've just missed this one? The perils of copy-paste coding I'm afraid...

  • Sql query runing slow with lower cost

    Hello
    I am working on Oracle 11g and AIX.I have one sql query which is ruing slow as reported by user.
    When i am commenting few line of code it is runing fast.
    I noticed that the execution plan cost of first query is less and second ...as cost of sccond qurey is more.But users are say it is runing fast.
    How it can possiable ?
    Any idea why second query is runing fast after commenting few columns in select and group by clause.
    Query 1
    SELECT PH.CTRL_NBR, PD.SEQ_NBR,PH.CNTRY,PH.SHIP_DATE, PHI.WAVE_NBR, PD.ID, PD.QTY,
    IM.PACK_QTY,
    IM.UNIT_VOL,
    IM.PACK_QTY,
    MAX(CD.PACK_QTY) AS CASE_QTY,
    IM.UNIT_WT
    FROM HDR PH,
    HDR_INTRNL PHI,
    DTL PD,
    HDR CH,
    CASEDTL CD,
    IMASTER IM
    WHERE PH.CTRL_NBR = PHI.CTRL_NBR
    AND PD.CTRL_NBR = PH.CTRL_NBR
    AND PD.QTY > 0
    AND SUBSTR(CD.ID, 1, 9) = SUBSTR(PD.ID, 1, 9)
    AND CD.CASENBR = CH.CASENBR
    AND CH.STAT_CODE BETWEEN '10' AND '90'
    AND IM.ID = PD.ID
    AND PHI.WAVE_NBR='EL57893'
    GROUP BY PH.CTRL_NBR, PD.SEQ_NBR, PH.CNTRY, PH.SHIP_DATE, PHI.WAVE_NBR, PD.ID, PD.QTY,
    IM.PACK_QTY,
    IM.UNITVOL,
    IM.UNITWT,
    IM.PACK_QTY
    Query 2 .
    SELECT PH.CTRL_NBR,
    PD.SEQ_NBR,
    PH.CNTRY,
    PH.SHIP_DATE,
    PHI.WAVE_NBR,
    PD.ID,
    PD.QTY,
    -- IM.PACK_QTY,
    -- IM.UNIT_VOL,
    -- IM.PACK_QTY,
    MAX(CD.PACK_QTY) AS CASE_QTY,
    -- IM.UNIT_WT
    FROM HDR PH,
    HDR_INTRNL PHI,
    DTL PD,
    HDR CH,
    CASEDTL CD,
    IMASTER IM
    WHERE PH.CTRL_NBR = PHI.CTRL_NBR
    AND PD.CTRL_NBR = PH.CTRL_NBR
    AND PD.QTY > 0
    AND SUBSTR(CD.ID, 1, 9) = SUBSTR(PD.ID, 1, 9)
    AND CD.CASENBR = CH.CASENBR
    AND CH.STAT_CODE BETWEEN '10' AND '90'
    AND IM.ID = PD.ID
    AND PHI.WAVE_NBR='EL57893'
    GROUP BY PH.CTRL_NBR, PD.SEQ_NBR, PH.CNTRY, PH.SHIP_DATE, PHI.WAVE_NBR, PD.ID, PD.QTY,
    --IM.PACK_QTY,
    --IM.UNITVOL,
    --IM.UNITWT,
    --IM.PACK_QTY
    Edited by: oradba11 on Sep 6, 2012 2:11 PM
    Edited by: oradba11 on Sep 6, 2012 2:12 PM

    oradba11 wrote:
    Hello
    I am working on Oracle 11g and AIX.I have one sql query which is ruing slow as reported by user.
    When i am commenting few line of code it is runing fast.
    I noticed that the execution plan cost of first query is less and second ...as cost of sccond qurey is more.But users are say it is runing fast.
    How it can possiable ? <snip>
    This doesn't address your question, but let me suggest that for your own sanity you start brining some formatting to your sql. And for the sanity of those on this forum of whom you expect assistance, you preserve that formatting through the use of the code tags (see the FAQ for details).
    I've done the first one for you, as an example of what I mean
    SELECT
         PH.CTRL_NBR
    ,     PD.SEQ_NBR
    ,     PH.CNTRY
    ,     PH.SHIP_DATE
    ,     PHI.WAVE_NBR
    ,     PD.ID
    ,     PD.QTY
    ,     IM.PACK_QTY
    ,     IM.UNIT_VOL
    ,     IM.PACK_QTY
    ,     MAX(CD.PACK_QTY) AS CASE_QTY
    ,     IM.UNIT_WT
    FROM
         HDR PH
    ,     HDR_INTRNL PHI
    ,     DTL PD
    ,     HDR CH
    ,     CASEDTL CD
    ,     IMASTER IM
    WHERE
         PH.CTRL_NBR = PHI.CTRL_NBR
       AND  PD.CTRL_NBR = PH.CTRL_NBR
       AND  PD.QTY > 0
       AND  SUBSTR(CD.ID, 1, 9) = SUBSTR(PD.ID, 1, 9)
       AND  CD.CASENBR = CH.CASENBR
       AND  CH.STAT_CODE BETWEEN '10' AND '90'
       AND  IM.ID = PD.ID
       AND  PHI.WAVE_NBR='EL57893'
    GROUP BY
         PH.CTRL_NBR
    ,     PD.SEQ_NBR
    ,     PH.CNTRY
    ,     PH.SHIP_DATE
    ,      PHI.WAVE_NBR
    ,      PD.ID
    ,      PD.QTY
    ,      IM.PACK_QTY
    ,     IM.UNITVOL
    ,     IM.UNITWT
    ,     IM.PACK_QTY

  • Re: How to converting from PL/SQL query to T-SQL query

    How to converting from PL/SQL query to T-SQL query... Its Urgent

    Download the
    SQL Server Migration Assistant for Oracle.  It will convert whole Oracle databases, or single queries or PL/SQL stored procedures.
    With caution that If your database is using Collation which is case sensitive SSMA will not work.SSMA doesnt guarantees 100% for conversion of Queries/stored proc /database if it fails to do so for some queries you will have to do it manually.
    But you can try
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • SQL Query - SCOM2012R2 Performance Counter

    Need some assistance with a SQL query against my SCOM DW. I want this to do a select within a select. The inner select must collect the raw data for a performance counter, for the last 5 minutes. But SCOM will only give me counters that collected in the
    last 5 minutes. What i want is the last value for every managed instance. - 1500 servers. 
    The outer SELECT must then filter this by doing a count on how many servers it collected a value for that are above 80% - and then divide that number by the total managed servers to give me a percentage of servers above 80% memory used. Eg - it counts 10
    servers are above 80%, but theres 100 servers - then gives me a final figure of 90%. 
    select (count(abc.DaValue)) from (
      select
        vManagedEntity.Path
        ,vPerformanceRule.ObjectName
        ,vPerformanceRule.CounterName
        ,AVG(vPerfRaw.SampleValue) AS DaValue
      from vPerfRaw
        join vPerformanceRuleInstance on vPerformanceRuleInstance.PerformanceRuleInstanceRowid = vPerfRaw.PerformanceRuleInstanceRowid
        join vPerformanceRule on vPerformanceRule.RuleRowId = vPerformanceRuleInstance.RuleRowId
        join vManagedEntity on vManagedEntity.ManagedEntityRowid = vPerfRaw.ManagedEntityRowId
      where vPerfRaw.Datetime > DATEADD(minute, -20, GETUTCDATE())
      and vPerformanceRule.ObjectName = 'Memory'
      and vPerformanceRule.CounterName = 'PercentMemoryUsed'
      GROUP BY Path, ObjectName, CounterName, Name
      Order by DaValue DESC) 
      as abc
    where abc.DaValue >= 80
    This statement gives me the result
    Msg 1033, Level 15, State 1, Line 15
    The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.
    Any ideas ?

    Latest update - 
    SELECT count(DISTINCT abc.server) as NoOfServers,
    count(case when abc.DaValue >= 90 then abc.DaValue end) 'MemoryAbove90%'
    FROM( select TOP 100 PERCENT 
    vManagedEntity.Path as Server ,vPerformanceRule.ObjectName 
    ,vPerformanceRule.CounterName ,AVG(vPerfRaw.SampleValue) AS DaValue
    from Perf.vPerfRaw join vPerformanceRuleInstance on vPerformanceRuleInstance.PerformanceRuleInstanceRowid = vPerfRaw.PerformanceRuleInstanceRowid
    join vPerformanceRule on vPerformanceRule.RuleRowId = vPerformanceRuleInstance.RuleRowId
    join vManagedEntity on vManagedEntity.ManagedEntityRowid = vPerfRaw.ManagedEntityRowId
    where vPerfRaw.Datetime > DATEADD(minute, -10, GETUTCDATE())
    and vPerformanceRule.ObjectName = 'Memory' and vPerformanceRule.CounterName = 'PercentMemoryUsed'
    GROUP BY Path, ObjectName, CounterName, Name
    Order by DaValue DESC)  as abc
    This gives me Total Servers collected from, and Total Servers found to have AVG collections over 90% for Memory Util. 
    My KPI states that I must only display the number of servers that are above 90%, for more than 10minutes.
    The problem with this is that when i run it over a 10 minute period, I get collections for about 40% of my managed servers only.
    I want to know if anyone has a better way of collecting the perf data over a 10 minute period ? 
    What i was thinking of doing is  running this query with time interval on 11 minutes, populating a temp table with the data, running the query
    again with time interval on 1 minute ago, and comparing the results. IF it finds a match, I know that the server has been over 90% memory util for 10 minutes - then i can count it ? Its probably not entirely accurate, but Im out of ideas. From here, i want
    to export the Values for Total Servers and TotalServersAbove90% into Excel, and build a guage off it that will reflect a % of Servers within SLA -Memory Util. 
    Im not entirely familiar with SCOM collection intervals, IF I run the query for the last 1 minute - It seems to skip alot of servers and only returns
    data from about 50, is that because its not cycling on those at that moment ? In which case my idea above wont work.
    UPDATE 2 - i think this will do it
    Our OPS guy just told me that we sample every 10min. So immediately im thinking, perhaps i can run the query for the last 11 minutes - IF more than
    1 sample is above 90%, the server is above 90% for more than 10min.
    But, when i run this query 
    select TOP 100 Percent Path, AVG(SampleValue) AS Value, DateTime  from Perf.vPerfRaw pvpr  inner join vManagedEntity vme on pvpr.ManagedEntityRowId
    = vme.ManagedEntityRowId  inner join vPerformanceRuleInstance vpri on pvpr.PerformanceRuleInstanceRowId = vpri.PerformanceRuleInstanceRowId  inner join vPerformanceRule vpr on vpr.RuleRowId = vpri.RuleRowId WHERE ObjectName = 'Memory' AND CounterName
    = 'PercentMemoryUSed' AND Datetime > DATEADD(minute, -1, GETUTCDATE()) AND SampleValue >= 90 GROUP BY Path, SampleValue, DateTime ORDER BY DateTime DESC
    I get a few servers, but some have more than 1 entry in the last 1 minute.  Which means that i cant compare 2 samples.
    Perhaps i could say if ALL samples collected per server in that 11 minute period are > 90, 
    then add 1 to MemoryAbove90% 

  • Combine multiple web services with the same SQL query into one

    Hello,
    I would like to ask a question regarding combine multiple similar web services into one. Can you please tell me if it is possible to combine 4-5 web services into one since they built on the same SQL query with 5 different criterias or condition so that the user can enter any of the 5 criterias to populate the data on the form instead of having 5 different web services?
    e.g Query: Select appName, permit#, address, phone, description, type, section, from table where appName = can be 'appName, permit#, address, phone, or description' to populate the rest of the data to the form.
    Does any one have ever done some thing like this in Workbench ES? If so please assist. I know it can be easier to build it in Visual Basic, C#, or dot.net but the requirement is to build it in workbench ES.
    Thanks in advance,
    Han Dao

    If you are querying for Name, PhoneNumber, and SSN, and you queried for all people with a phone number that started with 867, you would have a potentially long list of people.  So to keep track of all of the people, we store each record in XML complex elements.  The root node is just any name you want, and the repeating element is the complex element name. 
    So using the example from above, I'm going to specify the following:
         Root Node: Result
         Repeating Element: Person
    So now when I do a query, my resultXML will look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
    </Result>
    If your query returned multiple results (like ours would probably), it would look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
          <Person>
                 <Name>Han</Name>
                 <PhoneNumber>867-2169</PhoneNumber>
                 <SSN>222-22-2222</SSN>
          </Person>
    </Result>
    So Result and Person is just to give a little bit of structure to the xml result (containers really).  So you can name them whatever is helpful for you.
    The column name mappings map the query columns (Name, PhoneNumber, SSN) to some node in the XML (Name, PhoneNumber, SSN).  So you don't need to specify which field maps to what in the form.  Just copy the column names to the element name so you have a 1-to-1 naming.  If you want to manipulate the XML a bit though, you could do:
    Column Name               Element
    Name                            YourName
    PhoneNumber                Phone
    SSN                              Secret
    which would then make your xml look like:
    <Result>
          <Person>
                 <YourName>Alex</YourName>
                 <Phone>867-5309</Phone>
                 <Secret>111-11-1111</Secret>
          </Person>
    </Result>
    It lets you change the XML element names to whatever you want. Otherwise by default they take on their column names.
    In your form, you could bind to the WSDL through the Data Connections pane and point it to your web service.  This will then create form elements that you can just drag and drop allowing you to have the information available when the service gets ran.  Once the service is called, you can modify the field's data to get whatever information you need in order to populate other form fields. 
    If that is too confusing, feel free to send me your form (e-mail is on profile page) and I'll add comments to it to show you how to set up the form for the web service call (and also give me the link to your webservice)

  • Should every SQL query have its own event and command?

    Hello,
    I am developing an application using Cairngorm. My app uses SQL databases.
    I'm creating a separate event and command for each SQL query my application requires. I end up with many events  and commands - twenty different event/command pairs and I'm not even done yet.
    I was wondering if this is the right way to go, or if somehow similar SQL queries should be grouped together in the same event/command, and if so, how would I implement that elegantly?
    I've never used Cairngorm before so I want to make sure I do it correctly.
    Thank you for your time and any assistance you can offer.

    From my point of view, writing any SQL query or making queries directly from the presentation layer (eg. flex) to the db server it's almost always incorrect, awfull and maybe even insecure. The client layer should be more independent from the implementation layer as for instance the db server you are using. Instead you should call services on the server side and then they should have a DAO layer o whatever where the queries are done. You could then invoke one of this services and pass parameters that indicates what you want to do. (except you are using remoting where you will be invoking methods directly)
    Consider the case where you have a Java implemented service layer, you could be using hibernate to access the database and not writing a single line of SQL (maybe some HQL) and then you could do all the queries you need and return the beans retrieved from the database to the client layer using AMF3 and it's serialization/deserialization mechanisms. In a future you could modify your app to use JPA and then this layer use hibernate, then you client layer will remain the same the only changes will be done under the DAO layer.
    So again, in my opinion, db server should never be accesed directly from the presentation layer (Flex, Air or whatever) but from the backend services and this sould be completly abstract to the client layer. I have seen some people trying to do SQL queries from Flash but that it's giving a task to the Flash player it has never been intended to do. A miss use of the thin client the Flash Player is and an bad architecture.
    It would be great to hear others opinions.

  • SQL Query Issue - (inner not passing to outer query)

    Hello everyone:
    Here is my SQL query:
    SELECT RD.SITE,
      ROUND(
      (SELECT COUNT (DISTINCT PB.EMP_ID)
      FROM BOOK PB
      WHERE PB.EMP_ID IN
        (SELECT PB.EMP_ID FROM BOOK PB
      (SELECT COUNT (DISTINCT PB.EMP_ID)
      FROM BOOK PB
      WHERE PB.EMP_ID IN
        (SELECT PB.EMP_ID FROM BOOK PB
    WHERE MO.QUALIFIER > 4
      )* 100, 2) AS PERCENTAGE
    FROM BOOK PB
    LEFT JOIN POSITION MO
    ON PB.EMP_ID = PO.EMP_ID
    INNER JOIN PHYS_LOCATION RD
    ON MO.HOUSED         = RD.SITE_ID
    WHERE MO.ACTUAL_END IS NULL
    GROUP BY RD.SITE;Why am I getting the overall percentage for all Sites as opposed to each percentage calculating for each individual site. I grouped by RD.SITE, so I presumed it would calculate percentages for each site. What did I do wrong?
    Thank you for your assistance.

    AquaNX4 wrote:
    Hello everyone:
    Here is my SQL query:
    SELECT RD.SITE,
    ROUND(
    (SELECT COUNT (DISTINCT PB.EMP_ID)
    FROM BOOK PB
    WHERE PB.EMP_ID IN
    (SELECT PB.EMP_ID FROM BOOK PB
    (SELECT COUNT (DISTINCT PB.EMP_ID)
    FROM BOOK PB
    WHERE PB.EMP_ID IN
    (SELECT PB.EMP_ID FROM BOOK PB
    WHERE MO.QUALIFIER > 4
    )* 100, 2) AS PERCENTAGE
    FROM BOOK PB
    LEFT JOIN POSITION MO
    ON PB.EMP_ID = PO.EMP_ID
    INNER JOIN PHYS_LOCATION RD
    ON MO.HOUSED         = RD.SITE_ID
    WHERE MO.ACTUAL_END IS NULL
    GROUP BY RD.SITE;Why am I getting the overall percentage for all Sites as opposed to each percentage calculating for each individual site. I grouped by RD.SITE, so I presumed it would calculate percentages for each site. What did I do wrong?Because that is what you are requesting. Your scalar subquery to get the percentage is not restricted by the current site. Add filter columns to restrict the selected values for the computation
    Edited by: riedelme on May 8, 2013 7:26 AM

  • SQL query a Static LOV

    Hey everyone
    I'm trying to create a pivot report using a technique I'm reading on Ask Tom. In order to get it working I need to return the display values from a static LOV in a sub select statement without using the column attributes functionality available on page 422 of Apex.
    My static LOV has the following structure
    Display Return
    Monitorable 5
    Pay modifier/enabler 4
    Paid now and later 3
    Paid later 2
    Paid now 1
    My sub query has the following SQL where PAID_ID is equal to the return value of my Static LOV.
    select
    SCA.SCORE_ID AS "SCORE_ID",
    (SELECT MM1.TITLE FROM MET_METRICS MM1 WHERE MM1.MET_ID = SCA.MET_ID) AS "METRIC",
    (SELECT BU1.BU
    FROM MET_BU BU1,
    MET_SCORECARD MS1
    WHERE MS1.BU_ID = BU1.BU_ID
    AND MS1.SCORECARD_ID = SCA.SCORECARD_ID) AS "BUSINESS UNIT",
    SCA.PAID_ID AS "PAID_ID"
    from MET_SCORECARD_ALLOC SCA
    WHERE SCA.DELETED_BY IS NULL
    I'd like to replace PAID_ID with the display value of my LOV WITHOUT using the Column Attributes functionality available of page 422 of Apex.
    Is anyone able to advise whether it's possible to perform a join on the LOV directly in my sql query?
    Any assistance would be very much appreciated :)
    Dave

    Create a view for you LOV in de database :
    create or replace view v_display_return
    as
    select 'Monitorable' d, 5 v from dual
    union all
    select 'Pay modifier/enabler' d, 4 v from dual
    union all
    select 'Paid now and later' d, 3  v from dual
    union all
    select 'Paid later' d, 2  v from dual
    union all
    select 'Paid now' d, 1  v from dual
    ;Then you can use the view as the source of your LOV AND join it in your query.

Maybe you are looking for

  • Signing off of some apps so it doesn't use data...

    I don't ever sign out of facebook and had downloaded pandora radio as well.  Do I have to completely sign out of the app when I close it out in order to not use data when not in wi fi area?  Yesterday when I turned off pandora radio, I just paused a

  • Non-interactive FrameAccess.java and frame conversion woes

    Hello all, I am searching for a way to convert a webcam-acquired AVI file into a sequence of numbered TIFF images (one for each movie frame). While searching the 'net, I ran into the well-known sample called FrameAccess.java. Although it looks like a

  • Description of New API in CR 2011

    According to Coy's web seminar, Crystal 2011 provides API additions that make it easier to move from RDC to the .Net object model. Where can we find a description of these API additions?

  • ITunes Error 3194 for my iPod Touch?

    So I repeatedly tried to update my 4th Gen iPod to iOS 5 to no avail so I started searching ways to do it because every time I tried to update I would get iTunes Error 3194 "iPod could not be restored". I put my device into DFU mode like the guide su

  • Audio EDITING Er

    Greetings. I have a SoundBlaster Li've! sound card with driver 5.2..29. I recently formatted my hard dri've after my computer got hit with a virus. I just re-installed Avid Express Pro. However, now when I start it up, I receive the error: Exception: