Friday, September 13

Presentation on Aggregate Function





Tables used in this presentation are 

  • FactResellerSales(AdventureWorksDW)
  •  tblPopulation, l, m, n, p.


Query for creating tblPopulation

Create table tblPopulation 
(
   Country varchar(255),
   [State]  varchar(255), 
   City  varchar(255),
   [Population (in Millions)] int
);

----Inserting values into tblPopulation -------

 Insert into tblPopulation  values('India','Delhi','East Delhi',9),
('India','Delhi','South Delhi',8),
('India','Delhi','North Delhi',5),
('India','Delhi','West Delhi',7),
('India','Karnataka','Bangalore',9),
('India','Karnataka','Belur',2),
('India','Karnataka','Manipal',1),
('India','Karnataka','Mumbai',30),
('India','Karnataka','Pune',20),
('India','Karnataka','Nagpur',11),
('India','Karnataka','Nashik',6);


Query for creating table l

Create table l
 (
 region varchar(255),
 name varchar(255),
 amount decimal

 );

----Inserting values into l -------

 Insert into l  values
 ('region1', 'name1', 2000.00),
('region1', 'name2', 100.00),
('region1', 'name3', 500.00),
('region1', 'name3', 3400.00),
('region2', 'name1', 3233.00),
('region2', 'name2', 5000.00),
('region2', 'name2', 5344.00),
('region3', 'name1', 1200.00),
('region2', 'name2', 900.00),
('region4', 'name1', 2540.00);


Table p, m, n are shown below: