Need help in TSQL logic

  • I have two tables. TableA and TableB and both contains 3 columns. The amount which is entered in table A will be compared with 1 week data in table B to match the same amount in table B. For example if we enter 1500 in table A on 14th of jan it will be compared with table B between 15th of jan-21st of jan.

    It should be a 1-1 mapping.

    I guess I’m missing something In my logic. Please refer to the below attachment and help me in fixing this.

    The results of the query is displayed below and i need only 1-1 mapping.

    Query20

    A.1A.2B.2A.3B.3

    20001/14/20111/17/2011$1,500.00$1,500.00

    20001/20/20111/21/2011$1,500.00$1,500.00

    20001/25/20111/27/2011$1,500.00$1,500.00

    20002/3/2011 2/4/2011 $1,385.00 $1,385.00

    20002/10/20112/11/2011$1,500.00$1,500.00

    20002/10/20112/14/2011$1,500.00$1,500.00

    20002/11/20112/14/2011$1,500.00$1,500.00

    20002/15/20112/16/2011$1,125.00$1,125.00

  • Can you please provide:

    1) DDL to create your test tables

    2) DML to create test data

    3) The queries you have tried so far

    If you do not understand why I am asking please read this article; http://qa.sqlservercentral.com/articles/Best+Practices/61537/[/url]

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply