Querying from the result of another query.

The following query gives me a list of FaxIDs whose file path column does not start with C:\ and that haven't already been identified according to the identified table.
SELECT [FaxID] FROM [FaxQueue]
WHERE [FilePath] NOT LIKE 'C:\%'
AND [FaxID] NOT IN (SELECT [FaxID] FROM [Identified]);
I have some more code that send's an email to alert whoever that the following records don't have a correct filepath.
Now the list of FaxIDs need to be re-used to insert into the identified table. The identified table has just one column which keeps track of which FaxIDs that have been identified as not having a falid file path.
INSERT INTO [identified] VALUES (???)
I don't know what to stick in for the ?s... do I simply copy and paste my first query into the question marks?
How can I "save" the list of FaxIDs from the first query into some kind of data structure so I can send them in an e-mail (sp_send_dbmail)?
-Nothing to see. Move along.

We have 3 possible ways,
1. As subquery.
SELECT * FROM (
SELECT [FaxID]
FROM [FaxQueue]
WHERE [FilePath]
NOT LIKE 'C:\%'
AND [FaxID]
NOT IN (SELECT
[FaxID] FROM
[Identified])
) X
2. Using CTE(common table expression)
;WITH CTE AS (
SELECT [FaxID]
FROM [FaxQueue]
WHERE [FilePath]
NOT LIKE 'C:\%'
AND [FaxID]
NOT IN (SELECT
[FaxID] FROM
[Identified])
SELECT * FROM CTE
3. USING TEMP TABLE.
SELECT [FaxID] INTO #TEMPTABLE
FROM [FaxQueue]
WHERE [FilePath]
NOT LIKE 'C:\%'
AND [FaxID]
NOT IN (SELECT
[FaxID] FROM
[Identified]);
SELECT * FROM #TEMPTABLE
Regards, RSingh

Similar Messages

  • Problem of running the jump query from the result line

    Dear expert,
    I have a problem when running a jump query from the result line. Apparently, the values of the caracteristics haven't been sent to the jump target.  However, the configuration in RSBBS seems to be good as the jump works well from the other lines.
    Does anyone have some ideas on that?
    Thanks in advance!

    Hi,
    If you are supposed to bring across characteristic values to your target, then you will not be able to jump from the result line. The configuration expects that the values of the characteristic marked as being used in the jump are filled with unique values. When you use the result line as a source for your jump, the values in the result line will most likely be based on the sum of multiple characteristic values.
    Hth,
    -Jacob

  • How to calculate a column bases on the result of another column?

    Hello folks, i need some help with this senario.
    I don't know to explain this in a simple way, but i'll give it a go.
    I display a report in ApplicationExpress like this
    Each row displays a product where the user are going to make a forecast for 18 months ahead.
    [productname] [Stock] [sales] [PMonth] [NewstockMonth] [salesmonth1]      [ProductionMonth1]     [NewstockMonth1] ....
    [product1]______[10]____[5]____[0]_________[5]__________[10]_________[10]______________[5]
    [product2]______[2 ]____[0]____[0]_________[2]__________[5]__________[10]______________[ 7]
    [product3]______[30]____[20]___[0]_________[10]_________[5]_________[10]______________[15]
    Stock and sales are results of a function i have in my select.
    productionmonth is a text field where the user can edit the production and is saved in the table.
    So when the user has entered some inputs in the textboxes, and pressed the submit buttom, the newstockmonth columns
    should be calculated from the result i get from the previous month.
    newstockmonth = (stock-sales)+productionMonth
    newstockmonth1 =(newstockmonth-salesmonth1)+productionmonth1
    At this point my submit process has update in a for loop for each row. But i don't quite know how i can calculate every newstockmonth columns.

    Hi Klaus,
    your condition only works if the Shop is in the query. If I understood it correctly you have one query with
    Country   Shop   Total Sales
    and one with
    Country   Number of Shops   Total Sales
    and you don't want to restrict the second Total Sales but the Total Sales from the first query.
    Best regards
       Dirk

  • Removing ?xml version="1.0"? from the result

    Hi Friends
    How do we remove <?xml version="1.0"?> from the result if we have ran two query in one resultset
    e.g
    qryCtx := DBMS_XMLGEN.newContext('select ename, job from emp where empno > 7900');
    DBMS_XMLGEN.setRowSetTag(qryCtx,'employeedata');
    DBMS_XMLGEN.setRowTag(qryCtx,'emp');
    result := DBMS_XMLGEN.getXML(qryCtx);
    insert into temp_clob_tab values(result);
    DBMS_XMLGEN.closeContext(qryCtx);
    qryCtx := DBMS_XMLGEN.newContext('select * from dept');
    DBMS_XMLGEN.setRowSetTag(qryCtx,'departments');
    DBMS_XMLGEN.setRowTag(qryCtx,'dept');
    result := DBMS_XMLGEN.getXML(qryCtx);
    insert into temp_clob_tab values(result);
    DBMS_XMLGEN.closeContext(qryCtx);
    RESULT
    <?xml version="1.0"?>
    <employeedata>
    <emp>
    <ENAME>FORD</ENAME>
    <JOB>ANALYST</JOB>
    </emp>
    <emp>
    <ENAME>MILLER</ENAME>
    <JOB>CLERK</JOB>
    </emp>
    </employeedata>
    <?xml version="1.0"?>
    <departments>
    <dept>
    <DEPTNO>10</DEPTNO>
    <DNAME>ACCOUNTING</DNAME>
    <LOC>NEW YORK</LOC>
    </dept>
    <dept>
    <DEPTNO>20</DEPTNO>
    <DNAME>RESEARCH</DNAME>
    <LOC>DALLAS</L[i]Long postings are being truncated to ~1 kB at this time.

    Why do you want to get rid of the XML header ? If you want to concatenate the two values to produce a single XML document, I would recommend using XMLConcat or XMLAgg SQL functions.
    - Ravi

  • Format the returned record out from the result

    Hi All,
    Please help me again.
    i have this query...
    Query:
    select* from patient where id = '9'
    Result:
    id fluX fluY fluZ Created_on
    1 Y - - 06/15/2007 2:06:05 AM
    1 - - - 06/15/2007 2:06:05 AM
    1 - - Y 06/15/2007 2:06:05 AM
    I want only to return only one row out from the result above.
    ID      fluX        fluY       fluZ
    1 Y - Y
    Thanks in advance for help.
    Edited by: jresh on Jun 21, 2009 10:11 PM

    Hi jresh,
    Try following
    select id, max(fluX), max(fluY), max(fluZ), Created_on
    from patient where id = '9'
    group by id, Created_on;
    Please mark, if it help you
    Regards,
    Danish

  • Is it possible to reference one cell from the value of another?

    Is it possible to reference one cell from the value of another e.g.
    value of b1 = value of c(value of a1)
    So if a1 = 3 then b1 = c3, if a1 = 5 then b1 = c5.

    Excellent!
    Thanks Wayne. Just saved me many hours and a headache.
    Works like a dream.
    Thank you for your succinct (and accurate) answer.
    Mark

  • Every time I move emails from the inbox to another mailbox, then click on any mailbox, and then go back to the inbox, the moved messages have returned to the inbox

    Every time I move emails from the inbox to another mailbox, then click on any mailbox (the emails are there fine), and then go back to the inbox, the moved messages have returned to the inbox. I have moved them out of the inbox to other mailboxes again and again, but then they keep showing up in the inbox again as soon as I click on any mailbox other than the inbox. Very frustrating.
    This has only happened since I installed Mavericks on both my Macbook Pro and my iMac. It happens on both of them.
    Any ideas how to fix it?
    peter

    This may be one of the known issues with Gmail and it's IMAP settings working with Maverick's Mail.
    It all comes down to if you have the ALL MAIL folder visible or not via IMAP.
    If you do not, then you get the behavior you are describing.
    If you do have ALL MAIL visible, then there isn't a problem.
    Odd, I know.
    Anyway, check out this article on Wired which describes the problem and work around. You may have to click on the NEXT button at the top of the window to advance to the proper gallery image that describes this issue:
    http://www.wired.com/gadgetlab/2013/10/mavericks-issues-and-fixes/#slideid-23460 1

  • The preview of my brush is different from the results... Hard to explain (Pictures to help)

    Out of nowhere, my brushes started acting up. The preview of my brush is different from the results. Im attaching a picture of my cursor preferences as well as an example of whats going on!
    Please help me out!

    Which version of mac os x and version of photoshop are you using?
    See if going to System Preferences>Accessibility>Display and the setting the Cursor Size to Normal resolves the issue.

  • How to make a report based on the result of another report?

    Hi, All,
    I am a new guy in BW development
    I  made the report1, to show the "Total Sales in each country and each shop "
    (the fact table is "Order")
    now I want to make report2 "in each countries, the number of the shops, whose Total Sales >100000"
    Can I make the report2 based on the result of report1 (use the same fact table)
    thanks a lot
    QY

    Hi Klaus,
    your condition only works if the Shop is in the query. If I understood it correctly you have one query with
    Country   Shop   Total Sales
    and one with
    Country   Number of Shops   Total Sales
    and you don't want to restrict the second Total Sales but the Total Sales from the first query.
    Best regards
       Dirk

  • Calculate Percentage from the result of row result

    Expert
    I want to calculate percentage from row result
    For Ex
    Vendor
    ID  Record Percentage
    1001                                1002                   1003                                sum
    A   10   10%                     B   20   20%        C   70     70%                  100         100% 
    X    50   25%                    Y   125  62.5%      Z   25     12.5%               200          100%
    I want to get percentage such as A percentage 10/(102070), , X percentage 50/(5012525)
    not A 10/(10207050125+25) = 3.33%
    Please help me to get the percentage which client want to
    thanks

    Dear Lemine.
    Try using this..
    Percentage Share of Result (%CT)
    %CT<Operand>
    Specifies how high the percentage share is in relation to the result. The result
    means the result of aggregation at the next level (interim result).
    %CT Incoming Orders specifies the share of incoming order values of each
    individual characteristic value (for example of each customer) in relation to
    the characteristic's result (for example, customer of a division).
    Percentage Share of Overall Result (%GT)
    %GT <Operand>
    Specifies how high the percentage share is in relation to the overall result.
    The overall result means the result of aggregation at the next level in the list.
    In the calculation of the overall result, the dynamic filters (filters that were
    not already defined in the Query Designer) are included.
    Hope this helps u..
    Best Regards,
    VVenkat,,

  • How do I update all the records in a table from the contents of another table?

    Ok some situation information, I have a pervasive database that runs our accounting software that I am pulling a product list from.  I have that list stored in a table in SQL.  From time to time we update the records in the pervasive database and
    I want to be able to pull those changes into the SQL table.  I don't want to drop the table and recreate it because if a product is no longer active in the pervasive database it will not be returned by the query (if I return all the products even the
    inactive ones I will get thousands of records rather than just a few hundred) and I do not want to loose the products from the table that are now inactive.  
    So what I want to be able to do is pull the list from pervasive, compare it to the list that exists in SQL and update any changed records, add any new records, and leave any now missing records alone(missing from the pervasive list but present in the SQL
    list).  I have no trouble pulling the records from pervasive (now) but I am a little stumped on how to do the rest.  I am not sure if this is a situation to use MERGE or not.  I also do not really need this to be done on a regular basis as the
    changes do not happen often enough for that, the ability to manually trigger it would be enough.
    Any help would be appreciated.
    David

    Hi David,
    lets say you want to go with the lookup transformation.
    lets say u want to move the data from server A table A1 to Server B table B1
    What you need to do is the following:
    Cofigure the Lookup options as follows:
    - In general -> Specify how to handle rows with no macthing entries -> "Redirect Rows to no Match Output"
    -  In Connection -> Set the ole db connection to the Server B and select the table B you want to lookup the values in your case the table where you want to input the changes 
    -  In columns -> link the product column from table A to product column in table B. And do not select any rows to output.
    - now your component is ready next you need to input. so when u connect your lookup to the destination component You will get an option to select which output you want to use - use "Lookup No Match Output".
    this will actually just allow you to add only new items only to the table B.
    Teddy Bejjani - BI Specialist @ Netways

  • Creation of a new document from the output of another document.

    Hi all
    here is the scenario, If we are creating an debit memo request and debit memo to a customer, from the output of this debit memo we need to trigger the creation of another document( Ex credit memo to other customer) automatically, how we can do this?

    Hi,
    There is a simple solution provided by SAP to trigger the BILLING DOCUMENTS for Deliveries
    This is a standard process
    Setup a Job in SM36 for the program SDBILLDL and it will pick all the delivery document which are open on that particular Billing date
    and process the Billing documents
    Alternatively you can also create the IDOC to trigger the BILLING DOCUMENTS
    For which you need to setup the PARTNER PROFILES, MESSAGE TYPES, PORT, RFC DESTINATION, SEGMENT CREATION,
    But i would suggest you to go with the standard program to create the Billing documents
    regards,
    santosh

  • How do I install Elements 13 from the diskdrive on another computer?

    I bought a hardcopy of Elements 13. I want to install it on a Windows 7-desktop pc.
    However, this pc does not contain a diskdrive, therefore I want to install it from the diskdrive on my laptop.
    Both computers are in my home-network. I do have administrator rights. @From the desktop I can see the contents on the disk. I can even start to run and it is possible in the startscreen to choose installing Elements 13.
    Then, the resulting message is: "the specified file cannot be found"......
    How do I install the software?

    Your best bet is to download it and install it that way.  You can download the trial and use your serial number to activate it to full use (there is no difference between the trial and the full version other than the missing activation).
    PSE 13 Trial - http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop_elements
    (Info for PC vs Mac: https://forums.adobe.com/thread/1658959?sr=inbox&ru=3738552)
    PE 13 Trial - http://www.adobe.com/cfusion/tdrc/index.cfm?product=premiere_elements
    An alternative would be to copy the installation to a USB stick and plug that into your desktop

  • Is it possible to pass  a value from the list to another page..

    Hi everyone,
    I created a (list region) on a page and there is a FORM on the same page.I am trying to pass a value from that page to another page when the user selects one of the list entries.I tried with SET THESE ITEM.. WITH THESE VALUES in the list entries like
    SET THESE ITEMS--P13_TESTING_ID
    WITH THESE VALUES --&P10_ID.
    but its not working for me.I want to pass that value only when the user hits that list entry.Is it possible to do.
    Thanku
    phani

    Assuming P10_ID is an item on the FORM, I think , the form would have to be posted (submitted) for the item's vaue to be available in session state.

  • How to create new documet from the output of another document automatically

    Hi all
    here is the scenario, If we are creating an debit memo request and debit memo to a customer, from the output of this debit memo we need to trigger the creation of another document( Ex credit memo to another customer) automatically, how we can do this?

    Hi Dev,
    You need to create another report program for the other document along with the smartform.
    In the report program, you have to put your logic on how the other document has to be found when your document is created and the output be triggered.
    So in principle,
    There will be two programs linked to your output type.
    One will create the output of the document which is being created,
    Another program will automatically call the other target document in change mode and trigger the same output, during which the second program will be executed.
    Now the second program will create the output for the second document.
    Making copy controls wont help for this reqmt.
    Reward points if it helps.

Maybe you are looking for

  • Generation Error - when trying to publish a Java web service

    Hi All, I keep getting the following Generation Error -- java.util.NoSuchElementException_ when I'm trying to create a Java Web Service using the jdeveloper wizard. I have 2 entities and 2 stateless session beans acting as their facades. One entity h

  • Trial Version of Acrobat 10 Pro

    I am looking at 508 compliance and wanting to test Acrobat Pro. I don't have the Mac OS requirements to run Acrobat XI Pro. Is it possible to get a trial Version of Acrobat 10 Pro?

  • Ctrl-Alt shortcuts to switch modules not working

    I'm having trouble with LR 4.1 (Win 7 64 bit) recognizing keyboard input properly. Sometimes it just stops "seeing" ctrl-alt-n (where n=1, 2, 3...) to switch between modules (Library, Develop, etc.). I can do everything else with the keyboard (Tab to

  • How to calculate Last year in BEx Report

    Hi Experts I have a requirement to create report in BEx --> report output will be Amount, Diff in percentage(Plan-Actual),Last year My question how we calculate the Last year and actual minus plan difference in percentage

  • Chinese character support for 6210 Nav

    I brought my mobile in Australia which cannot support Chinese characters (Traditional). Is there any application i can install so that my mobile can support Chinese characters (Traditional)? Francis