Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Teradata sql grouping - response (1) by M.Saeed Khurram

$
0
0

Hi,
You can use the following query to get all the aggregations. But to get report in this particular format you might have to use some reporting tool. 

CT Test 
(
Date_key DATE
,Location VARCHAR(10)
,Vendor VARCHAR(10)
,call_cnt INT
)
PRIMARY INDEX (Date_key);

INS INTO Test('2013-09-09','Highlands','att'    ,1500 );
INS INTO Test('2013-10-28','Highlands','att'    ,200  );
INS INTO Test('2013-09-26','Utah     ','att'    ,800  );
INS INTO Test('2013-08-28','Cupertino','verizon',200  );
INS INTO Test('2013-09-30','Cupertino','Verizon',200  );
INS INTO Test('2013-09-30','San jose ','Verizon',400  );


 SELECT VENDOR, LOCATION, Date_key (FORMAT 'MMMM') , CALL_CNT, SUM(CALL_CNT) OVER (PARTITION BY VENDOR, LOCATION ORDER BY LOCATION) AS YearTotal,
 SUM(CALL_CNT) OVER (PARTITION BY VENDOR ORDER BY LOCATION) AS VendorTotal
 FROM Test;

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>