Newbie question.. help constructing SQL statement..
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Newbie question.. help constructing SQL statement..

  1. #1
    Join Date
    Apr 2011
    Posts
    54

    Newbie question.. help constructing SQL statement..

    Newbie question:

    Using MS SQL 2005..

    sample table structures and records:

    Table1:
    Batch_Name Time Documents_Processed
    ---------------- --------- -------------------------------
    MyBatches_2 | 2011-08-25 15:19:17.000 | 5
    MyBatches_1 | 2011-08-25 15:18:25.000 | 2


    Table2:
    Doc_Name Time Pages_Processed
    ---------------- --------- -------------------------------
    MyDocsB_4 | 2011-08-25 15:19:20.000 | 15
    MyDocsB_3 | 2011-08-25 15:19:19.000 | 8
    MyDocsB_2 | 2011-08-25 15:19:18.000 | 3
    MyDocsB_1 | 2011-08-25 15:19:17.000 | 1
    MyDocsA_1 | 2011-08-25 15:18:26.000 | 7

    Is it possible to have one SQL statement where:

    Getting the Table1.Documents_Processed for MyBatches_2 which is 5, minus 1 (minus one is constant) to get the result 4.

    then get the row count from Table2 based on the time from Table1 (any row in Table2 that is greater than 2011-08-25 15:19:17.000). the row count should be equal to 4.

    Note: these tables don't have any primary key and no relationships. My only way to trace the records are based on time.

    thanks in advance.
    Last edited by markenstein; August 25th, 2011 at 04:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center