How to query this ?

  • I have tables like TAB_Mobiles, TAB_Laptops. Both the table is of same structure. The fields are ID, Selling_Date,

    Total_No_Of_Items_Sold

    I need to create a report summary. We pass a selling date to the procedure. It should display the ID, sale summary.

    If it finds no items on that date, it should display 'NIL','No sale today'

    Can someone help please ?

  • sanujss (10/26/2010)


    I have tables like TAB_Mobiles, TAB_Laptops. Both the table is of same structure. The fields are ID, Selling_Date,

    Total_No_Of_Items_Sold

    I need to create a report summary. We pass a selling date to the procedure. It should display the ID, sale summary.

    If it finds no items on that date, it should display 'NIL','No sale today'

    Can someone help please ?

    Sanuj, this and your other posts look very much like coursework. If this is the case, then ask yourself how much you are likely to learn by not doing your homework. If this is not the case then I apologise.

    You haven't really provided all of the information needed to construct a solid tested solution. Please provide scripts to CREATE the tables and to populate them with some sample data. Make a start on your own homework: write a query which will retrieve rows, for a given selling date, from one of the tables. It couldn't get any simpler. Then post it here, and we'll talk about how to build on it to provide a solution to the question.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • ok. will do . thanks for ur reply

  • Please see the script

    CREATE TABLE TABMobile

    (

    SaleDate datetime,

    NoOfPiecesSold int

    )

    GO

    INSERT INTO TABMobile SELECT GETDATE(),12

    INSERT INTO TABMobile SELECT GETDATE()-1,20

    INSERT INTO TABMobile SELECT GETDATE()-2,35

    GO

    CREATE TABLE TABLatop

    (

    SaleDate datetime,

    NoOfPiecesSold int

    )

    GO

    INSERT INTO TABLatop SELECT GETDATE()-1,11

    INSERT INTO TABLatop SELECT GETDATE()-2,24

    GO

  • U havent specified anything about the ID column.

Viewing 5 posts - 1 through 4 (of 4 total)

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