SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Simplification
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hinduson
Yak Posting Veteran

Ghana
57 Posts

Posted - 10/17/2013 :  18:12:24  Show Profile  Reply with Quote
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

USA
37134 Posts

Posted - 10/17/2013 :  19:01:07  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

Ghana
57 Posts

Posted - 10/17/2013 :  19:04:14  Show Profile  Reply with Quote
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

Ghana
57 Posts

Posted - 10/17/2013 :  19:04:39  Show Profile  Reply with Quote
Please let me know if You need more details

Best Regards.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/18/2013 :  03:40:08  Show Profile  Reply with Quote
* 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

Nigeria
7 Posts

Posted - 06/01/2014 :  12:32:58  Show Profile  Reply with Quote
Please can some one explain to me the above by visakh16

Niit
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000