Query to find numeric range gaps within another range

Hi All,
Is it possible to find the solution with a SQL query for the following scenario.
I have done it in PL/SQL but want to do it in SQL. I have tried with analytic functions but not able to find the expected results.
Suppose i have a Table A with below data
Range_Start     Range_End
4                          16
20                        100
101                      200
250                      300
And Table B with below data
SubRange_Start     SubRange_End
7                               9
10                             13
20                             60
70                             80
110                           190
270                           300
i want to find the missing gaps in Table B within the ranges specified in Table A, like below
Output
start     end
4          6
14          16
61          69
81         100
101          109
191          200
250          269

Hi Dear,
Can I do reverse I mean I can get output as your question from your output as below:
I have this table
FID      STARTD ATE END DATE
1 01-MAY-10 03-MAY-10
1 09-MAY-10 11-MAY-10
1 03-JUN-10 04-JUN-10
2 03-JUN-10 04-JUN-10
2 04-AUG-10 04-AUG-10
2 06-AUG-10 06-AUG-10
I want like this.
FID FDATE
1 01-MAY-10
1 02-MAY-10
1 03-MAY-10
1 09-MAY-10
1 10-MAY-10
1 11-MAY-10
1 03-JUN-10
1 04-JUN-10
2 03-JUN-10
2 04-JUN-10
2 04-AUG-10
2 06-AUG-10
And:
How can i get date wise entry from Joining date to relieving date like..
FID      START DATE END DATE
1 01-MAY-10 03-MAY-12
1 09-MAY-10 11-MAY-11
2 04-AUG-10 04-AUG-11
I want like this.
FID FDATE
1 01-MAY-10
1 03-MAY-10
1 04-MAY-10
1 05-MAY-10
1 16-MAY-10
1 17-MAY-10
1 08-May-10
1 09-May-10
1 03-May-12
Can you please help me.
Thanks,
Edited by: 978452 on Dec 24, 2012 12:02 AM

Similar Messages

  • Advice with a query to find Accounts with activities within a given period ONLY

    Hello there,
    I am relatively new to Microsoft T-SQL and I was wondering if someone could help shed some light into a requirement I got...
    I have two tables in a database. One with accounts, and another with activities for such accounts. He is a simple diagram:
    *NOTE: Dates are in the DD/MM/YYYY format.
    Here is what I need to do:
    I need to get a list of all the accounts where the LAST activity was created in a date range, along with a count of activities that fall in such range. The idea behind this is to find out accounts with no activity after a certain period.
    I can certainly accounts with activities in a given range -- but that does not mean that there was no activities after the range.
    For example, if I look for Accounts with activities between Feb/2014 and Mar/2014, this query should NOT return the Contoso account, because it ha an activity after Mar/2014 (i.e.: Meeting with John on 15/Apr/14).
    Another example: If I query accounts with activities from 01/Jan/2014 and 03/Apr/2014, it should ONLY return the Adventureworks account:
    Adventureworks (3)
    [the number in parenthesis is the count of activities in that given time]
    This is because all other accounts had activities after 03/Apr/2014.
    Could someone please advise the best way to construct this query?
    Thanks in advance for the help!
    Regards,
    P.

    SELECT * FROM tbl WHERE CreatiinDate BETWEEN @firstactivities AND  lastactivites
    AND NOT EXISTS 
    (SELECT * FROM tbl t WHERE CreatiinDate>=@lastactivites
    AND
    tbl.AccountID=T.AccountID )
    OR
    SELECT * FROM tbl WHERE
    AccountID  NOT IN (SELECT
    AccountID FROM
    tbl t WHERE CreatiinDate>@lastactivites) 
    AND CreationDate BETWEEN
    @firstactivities AND  lastactivites
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Command to display only the latest modified directory within another directory and display the date of the last modify

    Okay I want to be able to run a .cmd file from my workstation to query a certain folder on remote clients. I want the command to find the specific folder within another folder and display the current date modified of that folder. I was
    able to use a command prompt to list the subdirectory that I was looking for on a specific computer by using the
    DIR command. It was something like this:
    dir C:\ParentFolder\ChildFolder /ad /o-d /b
    This shows a list of directories within the "ChildFolder" directory. The output would be something like:
    dir C:\ParentFolder\ChildFolder /ad /o-d /b
    folder1
    folder2
    folder3
    folder4
    So what I need now is a way to just show the folder in this group that had the most recent modification. For example if "folder2" was the most recently modified folder in the group, I would like my command line to just display "folder2 04/08/14
    04:13 PM
    Any help would be greatly appreciated.
    Cheers!

    Thanks Mike! This is what I was looking for! Much appreciated!
    I would like to run this as a script from my admin workstation that will query clients that have the "ChildFolder" directory. Is there a way to output the results to a .log/.txt file? I was working on .cmd that looked like this:
    {REM Verify current folder on remote clients
    del current-folder.log
    ECHO WorkStation-1 >> CurrentFolder/current-folder.log 2>&1
    ECHO ---------------- >> CurrentFolder/current-folder.log 2>&1
    DIR \\WorkStation-1\C$\ParentFolder\ChildFolder /ad /o-d /b >> CurrentFolder/current-folder.log 2>&1
    ECHO ---------------- >> CurrentFolder/current-folder.log 2>&1}
    My results looked something like this:
    " WorkStation-1
    Folder1
    Folder2
    Folder3
    I know it's ugly, but it was working (somewhat). I just needed to list only the most recently modified folder. Anyway, I've rambled enough.
    Is there a way to get my desired results using the PS command that you provided me?

  • Sql to find narrow ranges within broad ranges in the same table?

    hi,
    i'm building a query to find narrow ranges of zip codes within broader
    ranges in a table (for tax purposes). for example:
    LOW_ZIP HI_ZIP
    23400 23499
    need to find
    23401 23402
    23403 23440
    23441 23... you get the picture. :)
    so, each row has a low value and a hi value, then i need to run a
    subquery to take those values and find narrower ranges. any ideas?
    so far here's what i have - neeless to say it doesn't work. :P
    select sales_tax_id,
    from_postal_code,
    to_postal_code
    from ar_sales_tax a,
    (select from_postal_code as fpc,
    to_postal_code as tpc
    from ar_sales_tax
    where rowid = rowid) b
    where from_postal_code between b.fpc and b.tpc
    and to_postal_code between b.fpc and b.tpc
    and end_date is null

    here's the table layout...
    SQL> desc ar_sales_tax
    Name Null? Type
    LAST_UPDATE_DATE NOT NULL DATE
    LAST_UPDATED_BY NOT NULL NUMBER(15)
    CREATED_BY NOT NULL NUMBER(15)
    CREATION_DATE NOT NULL DATE
    LOCATION_ID NOT NULL NUMBER(15)
    RATE_CONTEXT NOT NULL VARCHAR2(30)
    ENABLED_FLAG NOT NULL VARCHAR2(1)
    START_DATE NOT NULL DATE
    END_DATE NOT NULL DATE
    FROM_POSTAL_CODE NOT NULL VARCHAR2(30)
    TO_POSTAL_CODE NOT NULL VARCHAR2(30)
    TAX_RATE NOT NULL NUMBER
    TAX_ACCOUNT NUMBER(15)
    LOCATION1_RATE NUMBER
    LOCATION2_RATE NUMBER
    LOCATION3_RATE NUMBER
    LOCATION4_RATE NUMBER
    LOCATION5_RATE NUMBER
    LOCATION6_RATE NUMBER
    LOCATION7_RATE NUMBER
    LOCATION8_RATE NUMBER
    LOCATION9_RATE NUMBER
    LOCATION10_RATE NUMBER
    ATTRIBUTE_CATEGORY VARCHAR2(30)
    ATTRIBUTE1 VARCHAR2(150)
    ATTRIBUTE2 VARCHAR2(150)
    ATTRIBUTE3 VARCHAR2(150)
    ATTRIBUTE4 VARCHAR2(150)
    ATTRIBUTE5 VARCHAR2(150)
    ATTRIBUTE6 VARCHAR2(150)
    ATTRIBUTE7 VARCHAR2(150)
    ATTRIBUTE8 VARCHAR2(150)
    ATTRIBUTE9 VARCHAR2(150)
    ATTRIBUTE10 VARCHAR2(150)
    ATTRIBUTE11 VARCHAR2(150)
    ATTRIBUTE12 VARCHAR2(150)
    ATTRIBUTE13 VARCHAR2(150)
    ATTRIBUTE14 VARCHAR2(150)
    ATTRIBUTE15 VARCHAR2(150)
    PROGRAM_APPLICATION_ID NUMBER(15)
    PROGRAM_ID NUMBER(15)
    PROGRAM_UPDATE_DATE DATE
    REQUEST_ID NUMBER(15)
    DATE_FIRST_USED DATE
    LAST_UPDATE_LOGIN NUMBER(15)
    SALES_TAX_ID NOT NULL NUMBER(15)
    SQL> spool off

  • Query to find first and last call made by selected number for date range

    Hi,
    query to find first and last call made by selected number for date range
    according to filter:
    mobile_no : 989.....
    call_date_from : 25-april-2013
    call_date_to : 26-april-2013
    Please help

    Hi,
    It sounds like you want a Top-N Query , something like this:
    WITH    got_nums   AS
         SELECT     table_x.*     -- or list columns wanted
         ,     ROW_NUMBER () OVER (ORDER BY  call_date      ) AS a_num
         ,     ROW_NUMBER () OVER (ORDER BY  call_date  DESC) AS d_num
         FROM     table_x
         WHERE     mobile_no     = 989
         AND     call_date     >= DATE '2013-04-25'
         AND     call_date     <  DATE '2013-04-26' + 1
    SELECT  *     -- or list all columns except a_num and d_num
    FROM     got_nums
    WHERE     1     IN (a_num, d_num)
    ;This forum is devoted to the SQL*Plus and iSQL*Plus front ends. This question doesn't have anything to do with any front end, does it? In the future, you'll get better response if you post questions like this in the PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the SQL forum FAQ {message:id=9360002}

  • SQL Select Records in a range but Not in another range

    Dear All
    I would like to know the best method to do the following task.
    There are records of meeting room usage
    room                        start_time
    Room A                2014-08-30 16:55:00.000
    Room C                      2014-08-30 13:20:00.000
    Room B                      2014-08-29 21:45:00.000
    Room A                      2014-08-29 22:00:00.000 
    I would like to get the rooms used at a range (e.g. 2014-08-30) but cannot be used in another range (e.g. 2014-08-29 or before)
    The result should be Room C only.
    My apporach is as follows
    SELECT room FROM RoomUsage
    WHERE start_time >= '2014-08-30 00:00:00' AND start_time <= '2014-08-30 23:59:59'
    AND room NOT IN (
    SELECT room FROM RoomUsage
         WHERE start_time < '2014-08-30 00:00:00'
    Is there any better and simple approach to achieve the same result?
    Thank you
    Best Regards
    swivan

    I tend to use EXCEPT or NOT EXISTS for this kind of thing as I find them more intuitive.  I also tend
    not to use Not In for JOINs due to its well-known problem with NULLs, ie if there is a NULL in the inner resultset the query short-circuits and you get no records.  I therefore prefer to use In / Not In for
    short lists eg Not In ( 'a', 'b', 'c' ).
    See for yourself:
    IF OBJECT_ID('tempdb..#roomUsage') IS NOT NULL DROP TABLE #roomUsage
    CREATE TABLE #roomUsage ( room VARCHAR(20) NOT NULL, start_time DATETIME2 NOT NULL )
    INSERT INTO #roomUsage
    VALUES
    ( 'Room A', '2014-08-30 16:55:00.000' ),
    ( 'Room C', '2014-08-30 13:20:00.000' ),
    ( 'Room B', '2014-08-29 21:45:00.000' ),
    ( 'Room A', '2014-08-29 22:00:00.000' )
    SELECT room
    FROM #roomUsage
    WHERE start_time >= '2014-08-30 00:00:00' AND start_time <= '2014-08-30 23:59:59'
    EXCEPT
    SELECT room
    FROM #roomUsage
    WHERE start_time < '2014-08-30 00:00:00'
    SELECT room FROM #roomUsage
    WHERE start_time >= '2014-08-30 00:00:00' AND start_time <= '2014-08-30 23:59:59'
    AND room NOT IN (
    SELECT room FROM #roomUsage
    WHERE start_time < '2014-08-30 00:00:00'
    -- Oops
    SELECT room FROM #roomUsage
    WHERE start_time >= '2014-08-30 00:00:00' AND start_time <= '2014-08-30 23:59:59'
    AND room NOT IN (
    SELECT room FROM #roomUsage
    WHERE start_time < '2014-08-30 00:00:00'
    UNION ALL
    SELECT NULL

  • Write a query for finding STDDEV for OLAP Cube

    Can anybody post a sample query which will find the standard deviation of sales for each month in the sample GLOBAL OLAP schema for Oracle 11g.
    The OLAP option automatically generates a set of relational views on cubes, dimensions, and hierarchies in Oracle 11g. So how can i write a query for finding the Standard deviation on these views.

    The easiest way to do this is to do this directly within the AW using a custom calculated measure. In AWM11g you can use the 11g custom measure wrapper to execute the STDDEV function:
    olap_dml_expression('function',data type)
    For example
    olap_dml_expression('STDDEV(cube_name, time_dimension_name)',number)
    You can then simply expose this calculated measure as another column in your SQL View and then there is no need to use the SQL equivalent. This means the calculation is performed inside the AW (which is as close to the source data as you can get) ensuring performance of the whole query remains high.
    If necessary you can take this a step further, if required, and wrap the STDDEV calculation within an OLAP DML program that would allow you to manipulate the status of time within the calculation. For example, you may want the STDDEV calc to only take into account the last 12 time periods rather than all time periods currently in status.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • Urgent please- need help to retreive all values within a range

    Hi,
    I need to retreive all the values(ID) within a range no matter if it is available in the database or not. I just need this in a sql query not a stored proc.
    for ex:
    select id, name, age
    from employee
    where id between (1 and 10)
    It returns
    id name age
    1 x 22
    3 y 26
    4 z 23
    10 c 32
    I need a query which should return values as follows.
    id name age
    1 x 22
    2
    3 y 26
    4 z 23
    5
    6
    7
    8
    9
    10 c 32
    quick replies will be appreciated.

    This is one way of doing
    select decode(id,null,lev,id),name,age from employee,(select level lev from dual
    connect by level < 11)
    where employee.id(+)=lev
    The above will display between 1 and 10. If you want to specify some other range then the below query will do,
    select decode(id,null,lev,id),name,age from employee,(select level lev from dual
    connect by level <=10
    minus
    select level lev from dual
    connect by level <5)
    where employee.id(+)=lev
    The above query will display between 5 and 10

  • Looking for a query to find first/last dates in overlapping dates...

    Hi,
    I'm looking for a query to find the first dates and last dates in a table conaining overlapping dates.
    I have a subscription table which has for each Customer start and end date for different subscriptions.
    I want to know the different ranges of date where there is subscriptions active.
    so if the table has this:
    CustID, Start date, end date
    1, 2008-01-01, 2012-06-06
    1 ,2009-01-01, 2011-01-01
    1, 2011-01-01, 2013-02-02
    1, 2013-01-01, 2013-08-08
    1, 2014-01-01, 2014-04-04
    I want to produce this result:
    custid, range start, range end
    1, 2008-01-01, 2013-08-08
    1, 2014-01-01, 2014-04-04
    the first row is the range identified from the 4 rows in my subscription table.
    thanks :)

    I think I found it...
    http://stackoverflow.com/questions/5213484/eliminate-and-reduce-overlapping-date-ranges
    let me try this method
    Hi,
    m writing to follow up with you on this post. Thanks for you posting a reply to share your workground. Was the problem resolved after performing the above link? If you are satisfied with the above solution, I’d like to mark this issue as "Answered".
    Please also feel free to unmark the issue, with any new findings or concerns you may have.
    Thanks,
    Sofiya Li
    If you have any feedback on our support, please click here.
    Sofiya Li
    TechNet Community Support

  • Move a query to from one user group to another user group

    Hi,
    it's possible to move a query (SQ01) from one user group to another user group ??
    Thank you.

    Hi,
    You can copy queries only if you have the authorization to make changes. Within your current user group, you can copy all queries. However, queries of other user groups can only be copied if the InfoSet used to define the query is assigned to both user groups.
    To copy a query, proceed as follows:
    1. Choose the name of the query you want to copy on the initial screen.
    If you do not know the name, use the directory functions to display the query directories and then choose a query to copy from there.
    2. Choose Copy.
    3. Enter the name and the user group of the query that you want to copy in the dialog box. Furthermore, you must enter a name for the copied query. The system proposes values for this.
    4. Choose Continue.
    This takes you to the initial screen. The query is added and appears in the query directory. You can now continue.
    Regards,
    Amit

  • Query to find unique combinations in a record set

    I need to build a SQL to identify unique combinations
    I have the following data structure -
    I have a table to capture characteristics. Each characteristic can be associated with one or more attributes. Each attribute can be assigned one or more values
    Characteristics are grouped under Characteristic set. A Family set is the highest level of grouping and is a group of characteristic sets.
    I need to find the unique combinations within each family set
    Ex.
    Family Set - F1
    contains Characteristic Set - S1 and S2
    S1 contains characteristics - C1, C2.
    S2 contains characteristics C3
    C1 contains 1 attribute a1 which can have two values v1 and v2
    C2 has 2 attributes a2 and a3 each of which can have one value say v2 and v3 respectively
    c3 has 1 attribute a4 which can take 4 values say v4, v5, v6, v7
    There is no pattern in terms of the number of values that can be assigned to an attribute, number of attributes for a characteristic, no of characteristics present in a set and number of set that can be associated with a family.
    Need to know the max no of unique combinations in a family. One combination for the above ex would be F1S1C1A1V1+F1S1C2A2V2+F1S1C2A3V3+F1S2C3A4V4
    Appreciate your help.
    Thanks
    Gopal

    Hi David,
    Thanks for you analysis
    But these are not the combinations I am looking for. The details below may explain my requirement -
    I am trying to build out a repository of flows supported by a product application.
    Characteristics are features in the application. Each feature can have one or more input parameters or attributes. Each parameter can support multiple values
    For ex. one characteristic could be
    Define Item
    Input parameters/attributes for item could be item class, item type etc. These attributes can take different values.
    Item Source could support values like Manufactured, Procured etc
    Item Type could support values like Raw Component, Finished Goods, Intermediates etc
    Characteristics are stored in a table with ID and name ; Attributes stored in attributes table with ID and named joined with characteristics id .. Values are stored in values table with value id and value and joined with the attribute id
    Based on the above ex., some of the supported combinations are Manufactured Component, Procured Component, Manufactured FG, Procured FG etc
    Characteristic set is a group of related characteristics or features.
    To take the above example further .. we can group Define Item + Define Product Structure as a characteristic set - Define Product
    Define product structure say has one attribute stucture type which takes two values complex and simple
    Characteristic set is stored in a set table with columns setid, setname, stepno, characteristic_id
    Now the combinations become - Manufactured Component with Complex Structure, Manufactured Component with Simple Structure, Manufactured FG with Complex Structure etc ...
    Family set are the supported flows in the application which groups the features to be executed.
    For ex. a Product Definition flow will comprise of
    Step 10 - Define Product (characteristic set)
    Step 20 - Cost the Product (another characteristic set with say one characteristic - cost method which supports value standard and average)
    Family set is stored in a family set table with column familyid, familyname, stepno, chstepid
    Based on the above ex, the product definition flow will have several combinations such as
    Combination 1 -
    Step 10 - Define Mfg Component with Complex Structure
    Step 20 - Cost the Component with Standard Costing
    Combination 2 -
    Step 10 - Define Mfg Component with Complex Structure
    Step 20 - Cost the Component with Average Costing
    and so on ...
    I need to derive the total number of unique combinations for each family set / flow
    Family Set > Step No > Characteristic Set (one characteristic set per step) > Step No > Characteristics (one characteristic per step) > Attributes (many attributes per characteristic) > Attribute value (many values per attribute)
    The complexity is quite large as the product supports several flows which can be executed through many combinations. We need to build out the combinations as a product footprint and I am trying to have it mapped through an apex application.
    Appreciate any help to map this information out.
    Thanks
    Gopal

  • Query to find the memory of database in oracle,sql

    Hi All,
    Please let me know the query to find the memory of database in oracle,sql.
    Thanks,
    sajith

    How do I find the overall database size?
    The biggest portion of a database's size comes from the datafiles. To find out how many megabytes are allocated to ALL datafiles:
    select sum(bytes)/1024/1024 "Meg" from dba_data_files;
    To get the size of all TEMP files:
    select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
    To get the size of the on-line redo-logs:
    select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
    Putting it all together into a single query:
    select a.data_size+b.temp_size+c.redo_size "total_size"
    from ( select sum(bytes) data_size
    from dba_data_files ) a,
    ( select nvl(sum(bytes),0) temp_size
    from dba_temp_files ) b,
    ( select sum(bytes) redo_size
    from sys.v_$log ) c;
    Another query ("Free space" reports data files free space):
    col "Database Size" format a20
    col "Free space" format a20
    select round(sum(used.bytes) / 1024 / 1024 ) || ' MB' "Database Size"
    , round(free.p / 1024 / 1024) || ' MB' "Free space"
    from (select bytes from v$datafile
    union all
    select bytes from v$tempfile
    union all
    select bytes from v$log) used
    , (select sum(bytes) as p from dba_free_space) free
    group by free.p
    This is what I use :P From http://www.orafaq.com/wiki/Oracle_database_FAQ#How_do_I_find_the_overall_database_size.3F

  • Query to find customers who have not purchased anything

    I have a query to find customers who have purchased what we call consumables (using item property) over a given period:
    SELECT T0.CardCode, T0.CardName, T0.DocDate, T0.DocTotal, T1.ItemCode, T1.Dscription,T1.quantity, T2.ItmsGrpNam
    FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry, OITG T2
    WHERE T0.DocDate BETWEEN '[%0]' AND '[%1]' AND T1.ItemCode like '2ssy%' AND  T2.ItmsGrpNam = 'consumable'
    I have another to show customers who have a particular type of equipment:
    SELECT T0.manufSN,T0.itemName,  T3.Name, T2.Address, T2.Street, T2.Block, T2.City, T2.County, T2.ZipCode
    FROM OINS T0 INNER JOIN OCRD T1 ON T0.customer = T1.CardCode INNER JOIN CRD1 T2 ON T1.CardCode = T2.CardCode Inner Join OCPR T3 ON T0.ContactCod = T3.CntctCode
    WHERE T0.manufSN like 'P%' AND T2.AdresType= 'S'
    What I would like is to find those customers who have this equipment (query 2) but who have NOT purchased and consumables in say the last year.
    I have tried using Excel by finding duplicates and taking those in query 1 from those in query 2 but it's very messy.
    Has anyone done anything like this or got any good ideas?
    Thanks

    Hi Ralph,
    Well, I enjoy teaching, so let's start at the beginning.  SQL is a fairly full-featured language, and it supports recursion and nesting.  That's why the books online often describe elements of the SQL statements as "expression" - it may be more than a field or a simple function occurring there.  Nesting is the little puppy we used here.
    Now, in your first post, you said:  "What I would like is to find those customers who have this equipment (query 2) but who have NOT purchased and consumables (query 1) in say the last year."
    So, our common point between the two queries is the customer, the CardCode.  That's what this part does:  F0.CardCode = T0.Customer.  In my internal convention, I used F for Filter.  So we only want the results in the filter where the CardCode matches the CardCode/Customer from the main query tables.  It's the sole contact point between the two queries.
    You also said you wanted only the items where they had purchased no consumables, which basically translates into: a count of the records equals 0.  Now, since all we're interested in from the second query, the consumables query is how many records we returned, we get rid of all the columns except for one that we apply a COUNT to.  After that, it's a simple criteria:  the result of the second query has to equal 0.  This is how the criteria looks after you take out all the details and put only the important brackets in:  (SELECT COUNT...FROM...WHERE...) = 0.
    This might be confusing at first, because most of the time we return recordsets from queries, but a standard feature of SQL is to return a value of any data type if the query returns a single row and a single column.  This wouldn't work at all if we had more than one column in our nested query (or would require lots of tweaking), and although it returns a number of results in the complete process of the whole SQL statement, it only returns one result for each row.
    Regards,
    Mark Dielmann
    Edited by: Mark Dielmann on Nov 13, 2009 12:30 PM - Forum doesn't support advanced formatting on answered questions.
    Edited by: Mark Dielmann on Nov 13, 2009 12:32 PM - Salutations and more formatting.
    Edited by: Gordon Du on Nov 13, 2009 10:35 AM - There are maximum characters limitation for correct format

  • Function Module to Compare Date within date Range

    Hi All,
            Does anyone know Function Module to Compare Date within date Range...For example i need to find whether 08/02/2006 falls in between 07/15/2006 and 09/15/2006......

    data: datum type sy-datum value '20070802',
          datum_low type sy-datum  value '20070730',
          datum_high type sy-datum value '20070930'.
    If datum between datum_low and datum_high.
    Endif.
    Regards,
    Rich Heilman

  • SQl query to find incompatibility defined

    If two programs are defined as incompatible with one another, the data these programs cannot access simultaneously must also be identified.
    This can be found from concurrent program->define from front end ebs login, but is there any SQL query to find this for a particular program or request set??
    Thanks in advance.

    Please search the forum before posting similar questions.
    Concurrent-Conflict
    Re: Concurrent-Conflict
    Thanks,
    Hussein

Maybe you are looking for

  • SQL PLUS QUESTIONS

    According to the tables and attributes below I need to solve 25 questions. I answered some of them and some of them I couldn't solve. I need your help please. school (sch_code, sch_name, sch_phone, sch_dean) advisor (adv_code, adv_fname, adv_lname, a

  • 11222 and 306 error!

    Hello! I've been surfing the past half hour for an answer to my question, but everything seems to be windows-related. Am I the first mac user who cannot get into the iTunes shop after the latest update? I keep getting the two errors 11222 and 306. Ca

  • Expressions in SSRS

    Experts, I have two datasets in SSRS. There is a column in each of the two datasets where I want to get the sum of this column in each sets to be obtained and again the two sums be summed up again. So, like SUM(sum(column), Dataset1)   +  sum(column)

  • PS Study Guide

    Hi Experts, I need documentation about the PS module since im starting to work with it. Thanks in advance. Chris.

  • Trying to download 4.4 version to a new laptop with my existing license # coming up invalid

    Hello, I am trying to download my Lightroom 4.4 to my new laptop, that I purchased on Ebay, and has worked fine on my Vista computer, and the girl I puirchased it from told me that would always be my license number on any computer I choose to downloa