Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Hinduson
Yak Posting Veteran
69 Posts |
Posted - 2013-10-17 : 18:12:24
|
Please How do I Simplify the following tasks:* Calculation of the total cost for a Particular Order.* Calculation of the total of all the orders placed by a particular Employee in a Particular MonthBest Regards. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-10-17 : 19:01:07
|
You'll need to provide more details, such as table structure.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Hinduson
Yak Posting Veteran
69 Posts |
Posted - 2013-10-17 : 19:04:14
|
Ok this is the Table I createdCREATE TABLE TRANSACTIONS_ORDERDETAILS(PurchaseOrderID int Identity (2,2) primary key nonclustered,Orderdate DATETIME DEFAULT (GETDATE()), CONSTRAINT CHECK_ORDERDATE CHECK (ORDERDATE < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),1)),QuantityOrdered varchar (50),CONSTRAINT check_ID5 CHECK (QuantityOrdered > 0 ),QuantityReceived INT null,CONSTRAINT check_ID6 CHECK (QuantityReceived >= 0 ),UnitPrice Money ,CONSTRAINT check_ID7 CHECK (UnitPrice > 0 ),OrderStatus varchar (50) not null,CONSTRAINT check_ID10 CHECK (Quantityreceived <= QuantityOrdered ),ItemID int,EmployeeID int,ReceivingDate datetime null,CONSTRAINT check_ID8 CHECK (ReceivingDate > Orderdate ))Best Regards. |
|
|
Hinduson
Yak Posting Veteran
69 Posts |
Posted - 2013-10-17 : 19:04:39
|
Please let me know if You need more detailsBest Regards. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-18 : 03:40:08
|
* Calculation of the total cost for a Particular Order.Apply GROUP BY over PurchaseOrderID field and apply SUM over (UnitPrice * QuantityReceived )* Calculation of the total of all the orders placed by a particular Employee in a Particular MonthGROUP BY on EmployeeID and DATEDIFF(mm,0,orderdate) and apply SUM over (UnitPrice * QuantityReceived )------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
sfalalu
Starting Member
7 Posts |
Posted - 2014-06-01 : 12:32:58
|
Please can some one explain to me the above by visakh16Niit |
|
|
|
|
|
|
|