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
(
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:
No comments: