I have mobile sales system, in which the salesman sends their stock request in handheld device and through GPRS the data comes to MS SQL database. I need o show a report that shows the which request is received at what time to warehouse administrator and by clicking on request number they can see the detail of that request (each item how much quantity) on daily basis.
WarehouseTransaction
WarehouseID TransactionID TransactionDate RequestedBy TransactionTypeID
27 36101398 2012-04-18 14:49:34.000 3 1
Warehousedetail
WarehouseID PackID Quantity
27 4 25.000000000
27 26 175.000000000
27 30 25.000000000
Whenever I run this query the data should be specific to today date only.
Best Answer
Unless I am missing something in your explanation, it sounds like you just want to do something like the following.
If your sample data is:
Then the query will be similar to this:
See SQL Fiddle with Demo
Which generates the result:
You did not specify what version of SQL Server but the
Cast(getdate() as date)
will work in SQL Server 2008+, if you are not in SQL Server 2008, then you can use the following:Edit, if you want your transactions to contain yesterday and today in SQL Server 2005 you can use:
See SQL Fiddle with Demo