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.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Simplification

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 Month

Best 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 Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Hinduson
Yak Posting Veteran

69 Posts

Posted - 2013-10-17 : 19:04:14
Ok this is the Table I created

CREATE 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.
Go to Top of Page

Hinduson
Yak Posting Veteran

69 Posts

Posted - 2013-10-17 : 19:04:39
Please let me know if You need more details

Best Regards.
Go to Top of Page

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 Month
GROUP BY on EmployeeID and DATEDIFF(mm,0,orderdate) and apply SUM over (UnitPrice * QuantityReceived )

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

sfalalu
Starting Member

7 Posts

Posted - 2014-06-01 : 12:32:58
Please can some one explain to me the above by visakh16

Niit
Go to Top of Page
   

- Advertisement -