combinations, nested queries

Hello everyone,

We need to change technologies according to the needs of the company and we would like to understand request.
Select t1.fld1 as class, v2.section, v1.duration,
T1.fld2 as start_date, end_date as t1.fld3,
(t1.fld2 + v2.section - 1) as sectiondate
Of
(select Fld1 as class, ((fld3-fld2) + 1) as the length)
from t1
) v1
, (select rownum as object section where rownum < 180) v2
t1
where t1.fld1 = v1.class
and v2.section < = v1.duration
rownum, nest queries, dot operator and combinations make us confused.
We need help with this.

Thanks in advance,

NY

Hello

I don't have your question. In your request, that you do not use one of the columns object, you simply use a virtual column rownum to get an output of 180 lines with value 1-179. This array with the value 1 to 179 you set v2 table in your SQL.

Concerning

Tags: Database

Similar Questions

  • Nested queries in Apex/BEEP Source?

    With the help of Apex 4.0.2.00.07, I have a master report / detail required that has a rather long header/footer and then lots of detail rows.  The ideal ratio would eventually something like the following:

    Paragraphs in header information

    Line 1

    ....

    Line 100

    Info from footer paragraph

    Is it possible for the Apex report queries to generate the XML to nest queries?  I know that I can throw it all in a single record by joining tables, but then I have to generate all the header information for each line instead of once for each master record.  I know that BEEP can handle it because I can do it for EBS by defining relationships of the query in the definition of data, but I can't seem to find a way to do it in the Apex report query.  I've seen several comments on this issue, but no definitive answer.  If anyone can help, I'd appreciate it.

    Jessica,

    You can not.  If you decide to put all the data in a single line, you can build your model to break in the header data.  The other option is to generate the report in the Pub BI and then call the report using webservice api bi pub.

    Introduction to the Web Services BI Publisher - 11g Release 1 (11.1.1)

  • XML not nested queries return no line plus


    Hello
    I have an urgent problem concerning the following:
    I've migrated the XMLDB queries below 11.2.0.1 to 11.2.0.3

    I registered just the schema

    () DBMS_XMLSCHEMA.registerSchema
    SCHEMAURL = > ' http://www.mywebsite.com/XML/Impex/order/2006-10-31 ',
    SCHEMADOC = > bfilename ('XMLDIR', 'order.xsd'),
    local = > TRUE,
    gentypes = > TRUE,
    gentables = > TRUE,
    CSID = > nls_charset_id ('AL32UTF8'));
    COMMIT;

    Some query works correctly and others not more are:
    Queries that do not work are those referring to XML elements nested as in "QUERY 2" below

    I think I missed a few steps of initialization for XMLDB.

    Order.xsd is the same in both cases

    SQLTypes and collections air well (they were created.
    (Do not know gentables = > TRUE is necessary in creating schema)

    Please give some feedback soon.
    Thank you very much in advance.

    In the following XML_FILE is XMLTYPE


    QUERY 1
    SELECT THIS WORKS PROPERLY

    --------------------------------
    SELECT
    ORDER_LEVEL1.order_no,
    TO_TIMESTAMP (ORDER_LEVEL1.order_date, ' YYYY-MM-DD "T" HH24:MI:SS.ff3 "Z" "").
    ORDER_LEVEL1.created_by, ORDER_LEVEL1.currency, ORDER_LEVEL1.customer_locale, ORDER_LEVEL1.order_status
    Of
    p (selection double XML_FILE),
    XMLTable)
    xmlnamespaces (default 'http://www.mywebsite.com/xml/impex/order/2006-10-31'),
    ' / orders/order "ADOPTION p.XML_FILE
    COLUMNS
    The "@order-no"order_no WAY,
    ORDER_DATE PATH "order date"
    created_by PATH "created by",
    currency of access road "currency."
    customer_locale "client-local," PATH
    order_status PATH "order status/tracking".
    ) ORDER_LEVEL1;
    -----------------------------------


    QUERY 2
    THIS SELECTION IS NOT WORKING NOW (returns the LINES No.)
    --------------------------------
    Select
    order_no as order_no, STOREID as STOREID, SHIPPINGMETHOD as SHIPPINGMETHOD
    Of
    (
    with mainq as
    (
    Select
    ORDER_LEVEL1.order_no as ORDER_NO,
    CUSTOMATT_LEVEL2.*
    Of
    p (selection double XML_FILE),

    XMLTable)
    xmlnamespaces (default 'http://www.mywebsite.com/xml/impex/order/2006-10-31'),
    ' / orders/order "ADOPTION p.XML_FILE
    COLUMNS
    The "@order-no"order_no WAY,
    custom_attribute PATH of XMLTYPE "custom-attributes/custom-attribute.
    ) ORDER_LEVEL1,.

    XMLTable (xmlnamespaces (default 'http://www.mywebsite.com/xml/impex/order/2006-10-31'), )
    "/ custom attribute" ADOPTION ORDER_LEVEL1.custom_attribute
    COLUMNS
    attribute_id PATH ' @attribute-id ',
    path value 'value '.
    ) CUSTOMATT_LEVEL2
    )
    Select
    order_no,
    STOREID, Max (decode(attribute_id,'storeId',TheValue)),
    Max (decode(attribute_id,'shippingMethod',TheValue)) SHIPPINGMETHOD
    of mainq
    Order_no group
    );

    ORDER FOR REFERENCE. XSD (only the rΘation segment to the elements in the query)

    < xsd: element name = "orders" xdb:defaultTable = "ORDERS" >
    < xsd: complexType mixed = "false" xdb:SQLType = "DMW_ORDERS" xdb:maintainDOM = "false" >
    < xsd: SEQUENCE >
    < xsd: element name = "command" type = "complexType.Order" xdb:SQLCollType = "DMW_ORDERS_COLL" minOccurs = "0" maxOccurs = "unbounded" > < / xsd: element > "
    < / xsd: SEQUENCE >
    < / xsd: complexType >
    < / xsd: element >

    < xsd: complexType name = "complexType.Order" xdb:SQLType = "DMW_ORDER" xdb:maintainDOM = "false" > "
    < xsd: SEQUENCE >
    < xsd: element name = "order date" type = "xsd: DateTime" minOccurs = "1" maxOccurs = "1" xdb:SQLType = "TIMESTAMP WITH TIME ZONE" >
    < xsd: annotation >
    < xsd: documentation > original date and time, the order was placed. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "created by" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "original-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "currency" type = "simpleType.Currency" maxOccurs = "1" minOccurs = "1" > < / xsd: element > "
    < xsd: element name = "customer-local" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "source code" type = "complexType.SourceCode" maxOccurs = "1" minOccurs = '0' > < / xsd: element > "
    < xsd: element name = "name-partner-affiliation" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "partner-affiliate-id" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "invoice-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "customer" type = "complexType.Customer" maxOccurs = "1" minOccurs = "0" > "
    < xsd: annotation >
    < xsd: documentation > information about the customer who placed the order. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "customer-order-reference" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "status" type = "complexType.OrderStatusSet" maxOccurs = "1" minOccurs = "0" > "
    < xsd: annotation >
    < xsd: documentation > Order status information. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "replace-code" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "description to replace" type = "simpleType.Generic.String.4000" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "replacement-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "replaced-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "current-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "cancel-code" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "cancel-description" type = "simpleType.Generic.String.4000" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "LineItem-product" type = "complexType.ProductLineItems" maxOccurs = "1" minOccurs = "0" > "
    < xsd: annotation >
    < xsd: documentation > product line items of the order. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "LineItem-giftcertificate" type = "complexType.GiftCertificateLineItems" maxOccurs = "1" minOccurs = '0' > < / xsd: element > "
    < xsd: element name = "transport-LineItem" type = "complexType.ShippingLineItems" maxOccurs = "1" minOccurs = '0' > < / xsd: element > "
    < xsd: element name = "expeditions" type = "complexType.Shipments" maxOccurs = "1" minOccurs = "0" > "
    < xsd: annotation >
    < xsd: documentation > shipments of the command. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "totals" type = "complexType.OrderTotals" maxOccurs = "1" minOccurs = "0" > "
    < xsd: annotation >
    < xsd: documentation > order total. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "payments" minOccurs = "0" maxOccurs = "1" type = "complexType.Payments" >
    < xsd: annotation >
    < xsd: documentation > payments used for the order. < / xsd: documentation >
    < / xsd: annotation >
    < / xsd: element >
    < xsd: element name = "remoteHost" type = "simpleType.Generic.String.40" minOccurs = "0" maxOccurs = "1" / > "
    < xsd: element name = "notes" type = "complexType.Notes" minOccurs = "0" maxOccurs = "1" / > "
    < xsd: element name = "external-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "external-order tracking" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "external-order-text" type = "simpleType.Generic.String" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
    < xsd: element name = "custom attributes" type = "sharedType.CustomAttributes" minOccurs = "0" maxOccurs = "1" / > "
    < / xsd: SEQUENCE >
    < xsd: attribute name = "order-no" type = "simpleType.Generic.String.256" use = "required" / > "
    < / xsd: complexType >

    .......................

    < xsd: complexType name = "sharedType.CustomAttributes" mixed = "false" xdb:SQLType = "DMW_CUSTOMATTRIBUTES" xdb:maintainDOM = "false" > "
    < xsd: SEQUENCE >
    < xsd: element name = "custom, the attribute" type = "sharedType.CustomAttribute" minOccurs = "0" xdb:SQLCollType = "DMW_CUSTOMATTRIBUTES_COLL" maxOccurs = "unbounded" / > "
    < / xsd: SEQUENCE >
    < / xsd: complexType >

    .......................

    < xsd: complexType name = "sharedType.CustomAttribute" mixed = "true" xdb:SQLType = "DMW_CUSTOMATTRIBUTE" xdb:maintainDOM = "false" > "
    < xsd: SEQUENCE >
    < xsd: element name = "value" type = "simpleType.Generic.String" minOccurs = "0" maxOccurs = "unbounded" / > "
    < / xsd: SEQUENCE >
    < xsd: attribute name = "id attribute" type = "simpleType.Generic.NonEmptyString.256" use = "required" / > "
    < xsd: attribute ref = "XML: lang" / >
    < / xsd: complexType >

    -XML (partial segment) example
    <? XML version = "1.0" encoding = "UTF-8"? "> < ordered xmlns ="http://www.mywebsite.com/xml/impex/order/2006-10-31">."
    < order order-no = "BLY0000001605" >
    < - > 2014 order date - 02-25T 11: 00:30.959Z < / date of order >
    ECOMMERCE < created-by > < / created by >
    BLY0000001605 < original-order - No. > < / original-order-not >
    < currency > $ < / currency >
    <>client-local en_US < / customer-local >
    < status >
    Placed > order tracking < < / order >
    < / status >
    < custom attributes - >
    < attribute custom attribute id = "storeId" > < value > < / value > < / custom attribute >
    < attribute custom attribute id = "shippingMethod" > < value > SAMEDAY_DLV < / value > < / custom attribute >
    < / custom attributes >
    < / order >
    < / order >

    I can't believe it. You are right.

    Removed the external selection and it worked! Mysteries of the Oracle :-)

    Thank you so much Odie

    (just a question: is 63 your favorite number or your birth year? you can answer me separately if you like...)

    GP_63

  • Combine 2 queries 1 result online results

    OK so I have 2 requests from 2 different tables, and I'm combining them into a single request as follows:


    Select * from
    (select col1 from tblA where col1 = 'val1'),
    (select col2 from tblB where col2 = 'val2') b


    and the results back as (I expect only 1 result of each query):

    col1, col2
    === ===
    AA... 11

    The problem is that when one of the subqueries returns no result, all of the query returns no results. I want a line of output, even if a query returns no results, as such:


    col1, col2
    === ===
    AA... NULL VALUE


    OR


    col1, col2
    === ===
    NULL VALUE... 11


    I looked at the different types of joins and unions, but have had trouble finding something simple that returns a single row - of the suggestions?

    Published by: 917372 on February 27, 2012 16:28

    Published by: 917372 on February 27, 2012 16:28

    Published by: 917372 on February 27, 2012 16:29

    Published by: 917372 on February 27, 2012 16:31

    Hello

    Welcome to the forum!

    Here's one way:

    SELECT     (SELECT col1 FROM tblA WHERE col1 = 'val1')     AS col1
    ,     (SELECT col2 FROM tblB WHERE col2 = 'val2')      AS col2
    FROM     dual;
    

    This will work as long as the two subqueries return 0 or 1 rank. If it is 0, the corresponding column will be NULL, as you requested.

    You could also each table of double outer join, or do an OUTER JOIN COMPLETE queries under 2. I think that the approach of scalar subquery (above) is the easiest way.

  • combination of queries:

    bank_id, COUNT (*) select 1) CONFIGURED TERMINALINFO group by BANK_ID


    (2) select bank_id, COUNT (*) CONNECTED, SUM(CASE WHEN station_status = 'UP' THEN 1 ELSE 0 END) UP_STATUS, SUM(CASE WHEN station_status = 'DOWN' THEN 1 ELSE 0 END) DOWN_STATUS of terminalinfo where station_status in ('UP', 'DOWN')
    and LAST_CONNECTED between January 31, 2012 00:00:00 ' and 31 January 2012 23:59:59 '
    Bank_id group;


    Can I combine the two queries and produce the result.

    If you could provide examples of data that would allow the results to check, but I think that will do...

     SELECT bank_id,
            COUNT(*) configured,
            COUNT(CASE
                      WHEN station_status IN ('UP', 'DOWN')
                      AND  last_connected BETWEEN TO_DATE('31/01/2012 00:00:00','dd/mm/yyyy hh24:mi:ss')
                                              AND TO_DATE('31/01/2012 23:59:59','dd/mm/yyyy hh24:mi:ss')
                      THEN
                          1
                      END
                  ) connected,
            SUM(CASE
                    WHEN station_status = 'UP'
                    AND  last_connected BETWEEN TO_DATE('31/01/2012 00:00:00','dd/mm/yyyy hh24:mi:ss')
                                        AND TO_DATE('31/01/2012 23:59:59','dd/mm/yyyy hh24:mi:ss')
                    THEN
                     1
                END) up_status,
            SUM(CASE
                    WHEN station_status = 'DOWN'
                    AND  last_connected BETWEEN TO_DATE('31/01/2012 00:00:00','dd/mm/yyyy hh24:mi:ss')
                                        AND TO_DATE('31/01/2012 23:59:59','dd/mm/yyyy hh24:mi:ss')
                    THEN
                     1
                END) down_status
     FROM
          terminalinfo
     GROUP  BY bank_id;
    

    HTH

    David

    Published by: Bravid on January 31, 2012 13:21

  • Need help combining 3 queries

    Hello ~

    I have several queries I want to be able to combine to get a report that looks like this:

    Troop property damage accident death
    7 2 1 B
    7 D 0 0
    A 6 1 0
    F 2 0 0
    Totals: 22 3 1


    Here are my questions below:
    select distinct officer_troop as "Troop",
             accident as "Accident",
             accident_type as "Type", 
             count(accident_type) as "Property Damage"
    from   pursuit
    where accident_type = 'PROPERTY'
    
    union all
    
    select count(accident_type)AS "INJURY"
    from pursuit
    where accident_type = 'INJURY'
    
    union all
    
    select count(accident_type)AS "FATALITY"
    from pursuit
    where accident_type = 'FATALITY'
    
    group by officer_troop,accident_type,accident
    order by count(accident_type) desc;
    I am able to get the first request appears correctly, but when I try to add the second and the third query, it does not display the way I want to.

    Anyone able to help? Thank you

    Deanna

    It seems that you need a pivot query, rather than a set of union alls

    for example:

    select officer_troop as "Troop",
             sum(decode(accident_type, 'PROPERTY', 1, 0)  "Property Damage"
    from   pursuit
    group by officer_troop
    

    I'll leave it to you to add additional columns as needed

  • The combination of queries? (division)

    {color: #000080} I have two queries what results I use to get the rate or percentage. Here they are: {color}



    < pre >
    SELECT
    COUNT (hd. ENTRY_ID)
    Of
    HPD_HELP_DESK_ASSIGNMENT_LOG,
    HPD_HELP_DESK hd,
    CTM_SUPPORT_GROUP ResolvedByGroup,
    CTM_SUPPORT_GROUP,
    CTM_SUPPORT_GROUP_ASSOC_LOOKUP
    WHERE
    HD. REPORTED_DATE & gt; = ((SYSDATE-TO_DATE (' 01/01/1970 00:00:00 ',' JJ-MM-AAAA HH24:Mi:SS')) * (24*60*60))-(24*60*60) reported 24 past hours. < br / > AND < br / > (hd.)) ASSIGNED_GROUP = "SERVICEDESK" GOLD hd. ASSIGNED_GROUP = "Z-SERVICEDESK") < br / > AND (hd. RESOLVED_BY_GROUP = "SERVICEDESK" GOLD hd. RESOLVED_BY_GROUP = "Z-SERVICEDESK") < br / > AND hd.resolved_by_group = hd.assigned_group < br / > AND hd.total_transfers = 0 < br / > AND (hd. LAST_RESOLVED_DATE - hd. REPORTED_DATE) & lt; (60 * 60 * 1) resolved in 1hours
    AND hd. AUTHOR = hd. ASSIGNEE_LOGIN_ID
    AND hd. SERVICE_TYPE = 0

    AND
    (HPD_HELP_DESK_ASSIGNMENT_LOG. INCIDENT_ENTRY_ID ()) = hd. ENTRY_ID)
    AND (CTM_SUPPORT_GROUP_ASSOC_LOOKUP. Login_id = hd. TRANSMITTER)
    AND (CTM_SUPPORT_GROUP_ASSOC_LOOKUP. DEFAULT_X = 0)
    AND (CTM_SUPPORT_GROUP. SUPPORT_GROUP_ID (+) is hd. ASSIGNED_GROUP_ID)
    AND (hd. RESOLVED_BY_GROUP = ResolvedByGroup.SUPPORT_GROUP_NAME (+))
    AND
    (
    CTM_SUPPORT_GROUP_ASSOC_LOOKUP. SUPPORT_GROUP_NAME in ('service DESK', "Z-SERVICEDESK")
    AND
    TRUNC (hd. REPORTED_DATE / 86400 + TO_DATE('12/31/1969 5:00:00 PM','MM/DD/YYYY HH:MI:SS AM')) BETWEEN to_date (October 28, 2008 ', 'dd-mm-yyyy') AND to_date (October 28, 2008 ', 'dd-mm-yyyy')
    )
    < / pre >

    {color: #000080}

    and {color}



    < pre >
    SELECT
    COUNT (hd. ENTRY_ID)
    Of
    HPD_HELP_DESK hd,
    CTM_SUPPORT_GROUP_ASSOC_LOOKUP
    WHERE
    HD. REPORTED_DATE & gt; = ((SYSDATE-TO_DATE (' 01/01/1970 00:00:00 ',' JJ-MM-AAAA HH24:Mi:SS')) * (24*60*60))-(24*60*60) - reported past 24 hours.)) < br / > AND hd. SERVICE_TYPE = 0 < br / > AND (CTM_SUPPORT_GROUP_ASSOC_LOOKUP. Login_id = hd. SUBMITTER) < br / > AND (CTM_SUPPORT_GROUP_ASSOC_LOOKUP. DEFAULT_X = 0) < br / > AND < br / > (< br / > CTM_SUPPORT_GROUP_ASSOC_LOOKUP.) SUPPORT_GROUP_NAME In ('Service DESK', "Z-SERVICEDESK") < br / > AND < br / > TRUNC (hd. SUBMIT_DATE / 86400 + TO_DATE('12/31/1969 5:00:00 PM','MM/DD/YYYY HH:MI:SS AM')) BETWEEN to_date (October 28, 2008 ', 'dd-mm-yyyy') AND to_date (October 28, 2008 ', 'dd-mm-yyyy') < br / >) < br / > < / pre > < br / > < br / > {color: #000080}

    all I get as a result of the first query is divided by the result of the second query. Is it possible to combine these two queries and come up with one that gives me the percentage/rate?

    Thanks in advance! {color}

    In a very simplistic way, they can be combined like this:

    WITH t1 AS
        (SELECT COUNT( hd.ENTRY_ID ) c1
           FROM HPD_HELP_DESK_ASSIGNMENT_LOG
              , HPD_HELP_DESK hd
              , CTM_SUPPORT_GROUP ResolvedByGroup
              , CTM_SUPPORT_GROUP
              , CTM_SUPPORT_GROUP_ASSOC_LOOKUP
          WHERE hd.REPORTED_DATE >=(( SYSDATE - TO_DATE( '1-1-1970 00:00:00', 'MM-DD-YYYY HH24:Mi:SS' ) ) *( 24 * 60 * 60 ) ) -( 24 * 60 * 60 ) --Reported last 24 hrs.
            AND ( hd.ASSIGNED_GROUP = 'SERVICEDESK'
             OR hd.ASSIGNED_GROUP = 'Z-SERVICEDESK' )
            AND ( hd.RESOLVED_BY_GROUP = 'SERVICEDESK'
             OR hd.RESOLVED_BY_GROUP = 'Z-SERVICEDESK' )
            AND hd.resolved_by_group = hd.assigned_group
            AND hd.total_transfers = 0
            AND ( hd.LAST_RESOLVED_DATE - hd.REPORTED_DATE ) <( 60 * 60 * 1 ) --resolved within 1hours
            AND hd.SUBMITTER = hd.ASSIGNEE_LOGIN_ID
            AND hd.SERVICE_TYPE = 0
            AND ( HPD_HELP_DESK_ASSIGNMENT_LOG.INCIDENT_ENTRY_ID(+) = hd.ENTRY_ID )
            AND ( CTM_SUPPORT_GROUP_ASSOC_LOOKUP.LOGIN_ID = hd.SUBMITTER )
            AND ( CTM_SUPPORT_GROUP_ASSOC_LOOKUP.DEFAULT_X = 0 )
            AND ( CTM_SUPPORT_GROUP.SUPPORT_GROUP_ID(+) = hd.ASSIGNED_GROUP_ID )
            AND ( hd.RESOLVED_BY_GROUP = ResolvedByGroup.SUPPORT_GROUP_NAME(+) )
            AND ( CTM_SUPPORT_GROUP_ASSOC_LOOKUP.SUPPORT_GROUP_NAME IN( 'SERVICEDESK', 'Z-SERVICEDESK' )
            AND TRUNC( hd.REPORTED_DATE / 86400 + TO_DATE( '12/31/1969 5:00:00 PM', 'MM/DD/YYYY HH:MI:SS AM' ) )
                BETWEEN to_date( '28-10-2008', 'dd-mm-yyyy' ) AND to_date( '28-10-2008', 'dd-mm-yyyy' ) )
        )
      , t2 AS
        (SELECT COUNT( hd.ENTRY_ID ) c2
           FROM HPD_HELP_DESK hd
              , CTM_SUPPORT_GROUP_ASSOC_LOOKUP
          WHERE hd.REPORTED_DATE >=(( SYSDATE - TO_DATE( '1-1-1970 00:00:00', 'MM-DD-YYYY HH24:Mi:SS' ) ) *( 24 * 60 * 60 ) ) -( 24 * 60 * 60 ) --Reported last 24 hrs.
            AND hd.SERVICE_TYPE = 0
            AND ( CTM_SUPPORT_GROUP_ASSOC_LOOKUP.LOGIN_ID = hd.SUBMITTER )
            AND ( CTM_SUPPORT_GROUP_ASSOC_LOOKUP.DEFAULT_X = 0 )
            AND ( CTM_SUPPORT_GROUP_ASSOC_LOOKUP.SUPPORT_GROUP_NAME IN( 'SERVICEDESK', 'Z-SERVICEDESK' )
            AND TRUNC( hd.SUBMIT_DATE / 86400 + TO_DATE( '12/31/1969 5:00:00 PM', 'MM/DD/YYYY HH:MI:SS AM' ) )
                BETWEEN to_date( '28-10-2008', 'dd-mm-yyyy' ) AND to_date( '28-10-2008', 'dd-mm-yyyy' ) )
        )
     SELECT c1 / c2 FROM t1, t2;
    

    Not knowing a lot about your tables and the selectivity of your questions, I am not sure how to move the two counts in the same query. You say that the first query is more selective than the second, so any effort to combine the two need to widen the scope of records returned by the first query must match that of the second query without losing selectivity of the County is in the first. This can be possible by relaxing the requirements in the where clause and moving them in a CASE statement in the COUNT function:

    COUNT(CASE WHEN expression THEN hd.entry_id ELSE null END)
    

    Published by: Sentinel on October 28, 2008 09:22

  • combining two queries?

    Table 1: importContact (e-mail, name, userIDFK, contactIDFK)
    Table 2: users (e-mail, name, userIDFK)

    Currently Im using two queries to insert lines in importContact to achieve what I want:

    (1) INSERT INTO importedContacts (email, name, userIDFK) VALUES (EMAIL HERE, NAME HERE, name of USER HERE)

    (2) importedContacts UPDATE I have
    SET i.contactIDFK = (SELECT u.userID FROM users WHERE i.email = u.email u)
    WHERE userIDFK =? AND EXISTS (SELECT u.userID FROM users WHERE i.email = u.email u)

    How I would combine the above two questions so instead of inserting first email, name, user name and contactIDFK then to do it in a single query

    As

    INSERT INTO importedContacts
    (email,name,userIDFK, contactIdFK )
    VALUES
    (EMAIL HERE,NAME HERE,USERID HERE, (SELECT u.userID FROM users u WHERE u.email = 'Email here') ) 
    
  • Nested queries

    I have this nested queryy but technology does not produce results as it should. The nested query works fine because I've alerted the values on, but I can't get the nested values to be written in the html code. Here is the code:

     tx.executeSql("select eventdate,strftime('%m',eventdate) as month, strftime('%Y',eventdate) as year from news where flag in ('E','A') and eventdate > '2011-7-6' group by date(eventdate,'start of month','+1 month','-1 day') having eventdate is not null order by date(eventdate,'start of month','+1 month','-1 day')", [],
    
                      function(tx,rs){
                       if(rs.rows.length > 0){
                           for(var i=0;i';
    
                                //alert(row.month+" "+row.year)
    
                                tx.executeSql("select subject,strftime('%m',eventdate) as month, strftime('%w',eventdate) as day from news where strftime('%m',eventdate) = strftime('%m','"+row.eventdate+"') and strftime('%Y',eventdate) = strftime('%Y','"+row.eventdate+"') and flag in ('E','A') order by eventdate", [],
    
                                    function(tx,rs2){
                                    //alert(rs2.rows.length);   
    
                                         for(var p=0;p'+row2.subject+'' ;
                                         }
    
                                    }
                                    , app.onError);
    
                                }
    
                           }//end for loop*/
    
                         showresultDiv.innerHTML += contentDiv+'';
                       }
    
                      }
    
                     , app.onError);
    

    Please can anyone help with this.

    Realizing the nature of the html5 application I decide not not my app like that. I made sure, after the main title are built I use an OnClick event to call a function that forwards the relevant data for me to make a dropdown menu with all the values that I needed to be out all at once on the charge.

  • You can combine multiple queries in one?

    I have a table of database options for additions to homes. I have another table for the categories for these options. Now I do a lot of queries for each individual category of the options. It looks like this:

    < / cfquery >

    < cfquery datasource = "applewood" username = "username" password = "password" name = "getCategory2" >

    SELECT *.

    From op_categories WHERE idOpCategories = 3

    < / cfquery >

    < cfquery datasource = "applewood" username = "username" password = "password" name = "getCategory3" >

    SELECT *.

    From op_categories WHERE idOpCategories = 4

    < / cfquery >

    .. and so on. Is there a way to make 1 query that finds each WHERE clause? I want it to look at this on a single page:

    Category 1 category 2 category 3

    ---------------         -----------------          ----------------

    Option 1 Option 1 Option 1

    Option 2 Option 2 Option 2

    Option 3 Option 3 Option 3

    Any help would be appreciated.

    What of this...

    SELECT *.

    Of op_categories WHERE idOpCategories in (3.4)

  • nesting queries on multiple sql files - possible?

    Hello

    I was wondering if the following would be possible, and if so what the syntax in sqlplus?

    Imagine I have a query that generates a table of data output. I can then refer to it and affix analytical functions on this one in a separate sql file?

    For example if I have the query:

    AB.sql
    select count (*)
    from (select sysdate from dual)
    I could this split into two files sql A and B?

    A.SQL
    select sysdate from dual
    B.SQL
    select count (*) from @C:\A.sql
    the result of the execution of B.sql would be 1.

    for now I really wonder if this is doable on a conceptual level, anyone know?

    Thank you

    Jon

    Yes, on the conceptual level, it is possible.

    cat a.sql
    select count (*)
    from (
    @b.sql
    )
    ;
    
    cat b.sql
    select sysdate from dual
    sqlplus scott
    
    SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 12 13:13:58 2010
    
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    
    Enter password:
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> set echo on
    SQL> @a.sql
    SQL> select count (*)
      2  from (
      3  @b.sql
      3  select sysdate from dual
      4  )
      5  ;
    
      COUNT(*)
    ----------
             1
    

    Best regards

    Maxim

  • How to combine multiple regex queries in a script?

    Hello

    is it possible to combine several queries regex in JavaScript? I export text from a database with custom labels and regex queries interpret the text AND character style replacements.

    example of

    Let's say my exported text is as follows

    "I have a very large text of < tag_bold > < / tag_bold > that includes a large number of styles of different characters, such as < tag_bold >"BOLD"< / tag_bold >, < tag_italic > italic < / tag_italic >, < tag_bold >"BOLD"with certain < tag_bold_underline > underlined words < / tag_bold_underline > < / tag_bold >. ,

    «to the words with different < tag_size-2 > text size < / tag_size-2 >»

    The result I want is

    "I have a very large text that includes a large number of styles of different characters, such as bold, italic,

    "BOLD", with a few words that are underlined, or never words with different text size.

    Note that all the tags open and close in the same paragraph and there's nested pairs of tags in some cases. If I run my requests (more than 20) of the outer pair the inner exception, i.e.:

    < tag_bold >... < / tag_bold >

    < tag_italic >... < / tag_italic >

    < tag_size-2 >... < / tag_size-2 >

    < tag_bold_underline >... < / tag_bold_underline >

    Thanks in advance for your help

    DPS

    If your character style name and tag name so I think it's a complete solution for you

    try code below:

    myDoc var = app.activeDocument;

    var charastyles = myDoc.characterStyles.everyItem () .name;

    for (a = 1;

    {

    repl_charastyles (charastyles [a])

    }

    function repl_charastyles (charstyle)

    {

    app.changeGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences.findWhat = '<' +="" charstyle="" +="" '="">' + '(.+?)';

    app.changeGrepPreferences.changeTo = ' $1 ';

    app.changeGrepPreferences.appliedCharacterStyle = charstyle;

    app.activeDocument.changeGrep ();

    app.changeGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences = NothingEnum.nothing;

    }

    Shonky
  • Help to combine the two queries with dependencies

    Combining two queries with dependencies:
    First ask: Returns USER_ID that has a type of access to a table with the OWNER (I also shoot the TLA of the USER_ID standard: ' of TLA #)

    Select distinct SUBSTR (DBA_USERS. Username, 2, 3) AS TLA

    DBA_USERS. Username USED_ID

    DBA_TAB_PRIVS. Owner OWNER

    from DBA_USERS

    DBA_ROLE_PRIVS

    DBA_TAB_PRIVS

    where DBA_USERS. Username = DBA_ROLE_PRIVS. Dealer

    and DBA_USERS.default_tablespace not in ('SYSTEM', "SYSAUX")

    and DBA_USERS. Username like would be %'

    and DBA_ROLE_PRIVS. Granted_role = DBA_TAB_PRIVS. Dealer

    and SUBSTR (DBA_USERS. Username, 2, 3) <>DBA_TAB_PRIVS. Owner

    ;

    Example of results (red font used in the last citation):

    TLA USED_ID OWNER

    --- ------------------------------ ------------------------------

    DGTX999 GTX GRR

    DGTX999 GTX ABG

    DGTX999 GTX HTC

    FWS DFWS999 GRR

    OCN DOCN999 GRR

    RHR DRHR999 DAS

    ETM DETM999 DAS

    FWS DFWS995 DAS

    CD DCDS999 DAS

    ABE DABE999 DAS



    Second request: matches the USER name (same standards as above) and MACHINES (filter PC connections) and the number of connections made of

    Select DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    COUNT (*) AS CONN_COUNT

    of DBA_HIST_ACTIVE_SESS_HISTORY

    DBA_USERS

    where DBA_HIST_ACTIVE_SESS_HISTORY. User_id = DBA_USERS. User_id

    and DBA_USERS. Username like would be %'

    and DBA_HIST_ACTIVE_SESS_HISTORY. Machine not as "WINAD%\%-%".

    Group of DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    order by 1

    3 desc;

    Example of results (red font used in the last citation):

    MACHINE CONN_COUNT USERNAME

    --------------- ------------------------- ----------

    DFWS999 home13e0 7557

    DGAM800 vu1246 37

    DGAM999 vu1246 2558

    DABE999 back18cb 4639

    DINL888 home162f 84

    DFWS999 WINDAD\OMHQ58BF 178

    DCDS999 back18cb 788

    DGTX999 home18c8 7

    DGTX999 home13d3 62

    DOCN999 vu1261 44

    DFWS999 back1976 3

    DCDS999 home18c8 173

    DGTX999 home19c9 13

    What I'd like to have (just made two first USER_IDs from the first query) (COL duplicated for each separate owner 1-4).  So 3 machines and 3 owners would result in 9 lines (I could reorganize the collar and use a 'pause'):

    TLA USED_ID MACHINE CONN_COUNT OWNER

    --- ------------------------------ ------------------------- ---------- ------------------------------

    GTX DGTX999 home13d3 62 GRR

    Home18c8 GTX DGTX999 7 GRR

    DGTX999 GTX home19c9 GRR 6

    GTX DGTX999 home13d3 62 ABG

    DGTX999 GTX home18c8 ABG 7

    DGTX999 GTX home19c9 6 GBS

    GTX DGTX999 home13d3 62 CTH

    DGTX999 GTX HTC 7 home18c8

    DGTX999 GTX home19c9 6 HTC

    FWS DFWS999 home13e0 7557 GRR

    FWS DFWS999 WINDAD\OMHQ58BF 178 GRR

    FWS DFWS999 back1976 GRR 3


    So it would be logically read: TLA as USER_ID of MACHINE, CONN_COUNT consultation times: OWNER information.

    Thought as only those with the necessary values. Just try this and let me know in the case of all conflicts in the output.

    WITH T1 AS)

    Select distinct SUBSTR (DBA_USERS. Username, 2, 3) AS TLA

    DBA_USERS. Username USED_ID

    DBA_TAB_PRIVS. Owner OWNER

    ROWNUM RN

    from DBA_USERS

    DBA_ROLE_PRIVS

    DBA_TAB_PRIVS

    where DBA_USERS. Username = DBA_ROLE_PRIVS. Dealer

    and DBA_USERS.default_tablespace not in ('SYSTEM', "SYSAUX")

    and DBA_USERS. Username like would be %'

    and DBA_ROLE_PRIVS. Granted_role = DBA_TAB_PRIVS. Dealer

    and SUBSTR (DBA_USERS. Username, 2, 3) <> DBA_TAB_PRIVS. Owner),

    () AS T2

    Select DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    COUNT (*) AS CONN_COUNT

    of DBA_HIST_ACTIVE_SESS_HISTORY

    DBA_USERS

    where DBA_HIST_ACTIVE_SESS_HISTORY. User_id = DBA_USERS. User_id

    and DBA_USERS. Username like would be %'

    and DBA_HIST_ACTIVE_SESS_HISTORY. Machine not as "WINAD%\%-%".

    Group of DBA_USERS. Username

    DBA_HIST_ACTIVE_SESS_HISTORY. Machine

    order by 1

    3 desc)

    SELECT T1. TLA

    ,         T1. USED_ID

    ,         T2. MACHINE

    ,         T2. CONN_COUNT

    ,         T1. OWNER

    FROM T1

    T2

    WHERE T1. USED_ID = T2. USER NAME;

  • Combine queries to get the result set with max Y

    Hello
    I use forms 6i and db 10.2.0.1.0

    With the query below
    Select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete from usr_file_access_master
    Where ufam_ecode = '0004108';
    the result set is
    UFAM_USRGRP     UFAM_FILEGRP    UFA UFA UFA UFA
    --------------- --------------- --- --- --- ---
    MGMNT           CV              Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   N   N   N
    EMPLOYEE        PERSONAL        Y   N   N   N
    Another query
    Select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
    Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
    and usr_usrgrp_lnk.uul_ecode = '0004108'
    gives the result
    UUL_USRGRP      UFL_FILE_GRP    UFL UFL UFL UFL
    --------------- --------------- --- --- --- ---
    MGMNT           GENERAL         Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   Y   N   N
    MGMNT           CV              Y   N   N   N
    I need to combine these two queries to get a separate result set with maximum Y

    Like here "MGMNT CV" is repeated in both the result set, but the first has more, then it should come from the combined result set. reverse-case also the same (such as "EMPLOYEE GENERAL")

    So I want to combine the queries so that I get the result as set below
    UserGroup       FileGroup       Rd Wrt Owrt Del
    --------------- --------------- --- --- --- ---
    MGMNT           GENERAL         Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   Y   N   N
    MGMNT           CV              Y   Y   Y   Y
    EMPLOYEE        PERSONAL        Y   N   N   N
    Please help me to combine these queries

    Published by: Divya on August 14, 2011 21:24
    Changed the result set and the last exit

    NOT TESTED!

    select y.uul_usrgrp,
           y.ufl_file_grp,
           greatest(ufl_read,nvl(ufam_read,' ')) ufl_read,
           greatest(ufl_write,nvl(ufam_write,' ')) ufl_write,
           greatest(ufl_overwrite,nvl(ufam_overwrite,' ')) ufl_overwrite,
           greatest(ufl_delete,nvl(ufam_delete,' ')) ufl_delete
      from (select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete
              from usr_file_access_master
             Where ufam_ecode = '0004108'
           ) x,
           (select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete
              from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
             Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
               and usr_usrgrp_lnk.uul_ecode = '0004108'
           ) y
     where y.uul_usrgrp = x.ufam_usrgrp(+)
       and y.ufl_file_grp = x.ufam_filegrp(+)
    

    Concerning

    Etbin

    Edited by: Etbin on 14.8.2011 13:08
    deleted by group

  • Using the cursor to another (nested cursors) cursor objects...?

    Now, I'm pretty sure that's not possible, but as a last thought of the station, it would not hurt to ask.

    I have a number of fairly complex cursors in PL/SQL (all beautifully packaged upwards), which are used in a number of other different queries for reporting. Because the same cursor is reused several times in different contexts, I want set the cursor once, then use it as a subquery in the other queries. This will also help as if I place the SQL directly in other queries, then it will be necessary propagate the changes to the base query in all other queries which use - and that it will be maintained by a large team that goes forward, it would be wide open to things being missed... (not that I don't trust my colleagues or anything like that...!)

    So, in brief and simple terms, if I;

    CURSOR curDateList (pi_start_date AS, pi_end_date IN DATE)
    IS
    SELECT pi_start_date + rownum - 1 when
    FROM (select '1' sys.dual connects by level < = (pi_end_date - pi_start_date + 1));

    that returns a list of the dates of pi_start_date to pi_end_date, and I want to integrate in another slider like;

    CURSOR curEmpWork (pi_start_date AS, pi_end_date IN DATE)
    IS
    SELECT e.employee_id, dl.when, e.work_pattern
    OF e xxx.emp_work_patterns,.
    DL curDateList (pi_start_date, pi_end_date)
    WHERE dl.when = e.roster_date
    ORDER BY e.roster_date;

    (Needless to say that queries are much more complex and many!)

    I reached the required result by using the pipeline table functions that just open the first cursor and run each line, but am frequently end up using multiple nested functions to achieve and I see marked in this way, then the performance degradation that comes to nest queries within the other runs a lot faster. As a nested query is just a nested cursor, it seems that this is possible, but I'm not only have no chance - I am struggling to find something that says that it of possible or not (which made me think I am barking the wrong tree here!)

    Any help would be greatly appreciated.

    No, it is not possible, but have you thought of creating a view instead?

Maybe you are looking for

  • Continually download messages in Inbox

    I've recently set up TB on a new laptop and everytime I open the machine and go to get my emails is so sloooow seems to be always download 12 18 emails in the Inbox or 21 of the 28 in Inbox or something like that and don't let me do much until it's o

  • Satellite 2400 - 103: sound does not work after installing SP2

    Hello!I had to install Windows XP Service Pack 2 to keep my Windows Update. Unfortunately, my audio device does no more work because XP is considered a potential threat.When first, I installed SP2 last year and saw that I had no sound on my PC, I jus

  • I wiped clean my HP computer with the disk sanitizer in the BIOS settings...

    s/n [personal information] p/n KR971UT Used the disk Sanitizer, now I get a "non-system disk error" message on my laptop hp 6730 b. I tried to insert the "CD of OS for xp" disc... flashing underscore appears but never a message press buttons it flash

  • Files and folders invisible

    I have recently started using a computer with Windows XP 64 bit and have noticed that the records seem to "disappear" at will.  The folder and or file, I try to access is there, but neither Windows Explorer nor the program, I am trying to access find

  • After cropping the photo, is there a way to prevent the function from the previous version?

    After cropping a photo, I don't want that it is original to never be recoverable. Is there a way to do this? I just discovered the tool of the previous version. Can it be disabled or the photo "permatized" sort? Thank you