Compute and Compute By

CREATE TABLE InventoryInfo
(
SL_No INT IDENTITY PRIMARY KEY,
InventoryMasterName char(50),
StateId CHAR(10) FOREIGN KEY REFERENCES StateInfo(StateId),
InventoryDate DATE,
InventoryAmount MONEY
)

INSERT INTO InventoryInfo VALUES
('Nisha Singh' , 'R0001' , '01/02/2015',5000),

('Nisha Singh' , 'R0001' , '02/02/2015',3500),

('Nisha Singh' , 'R0001' , '03/02/2015',4000),

('Prince' , 'R0001' , '01/02/2015',5340),

('Prince' , 'R0001' , '02/02/2015',4300),

('Prince' , 'R0001' , '03/02/2015',5000),

('Prince' , 'R0002' , '01/02/2015',5980),

('Prince' , 'R0003' , '01/02/2015',8790),

('Prince' , 'R0004' , '01/02/2015',5000),

('Nisha Singh' , 'R0002' , '01/02/2015',9800),

('Nisha Singh' , 'R0003' , '01/02/2015',8760),

('Nisha Singh' , 'R0004' , '01/02/2015',34230),

('Nisha Singh' , 'R0004' , '02/02/2015',15000)




Select * from InventoryInfo
COMPUTE sum(InventoryAmount)

/*Syntax for COMPUTE By:
Select <Col_Name_List> From <Table_Name>
[Where <Condition>]
Order By <Col_X>
COMPUTE <Aggregate_Function(Col_Name)> By <Col_X>
*/

Select * from InventoryInfo
Order By InventoryMasterName
COMPUTE sum(InventoryAmount) By InventoryMasterName
Compute and Compute By Reviewed by Rupesh on 20:54 Rating: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.