complex group by query
Saaz EnaJul 21 2008 — edited Jul 21 2008Hi,
Pls someone help me to solve the below query
SQL> SELECT FACILITY_TYPE, CONTACT_TYPE, POI FROM POI ORDER BY FACILITY_TYPE, CONTACT_TYPE; FACILITY_TYPE CONTACT_TYPE POI------------------------------ ------------ ----------Auto Service and Maintainance 1 53Auto Service and Maintainance 1 44Auto Service and Maintainance 3 44Auto Service and Maintainance 4 53Auto Service and Maintainance 4 53Auto Service and Maintainance 4 44Auto Service and Maintainance 5 44Auto Service and Maintainance 5 53Auto Service and Maintainance 5 53Clothing Store 3 51Clothing Store 3 51Golf Course 1 40Golf Course 1 40Golf Course 1 40Golf Course 3 40 15 rows selected
The output shold look like
FACILITY_TYPE CONTACT_TYPE COUNT_GP_POI COUNT_PER_POI------------------------------ -------------------- ------------ -------------Auto Service and Maintainance 1 2 1Auto Service and Maintainance 4 1 1Auto Service and Maintainance 3 1 1Auto Service and Maintainance 3 1 2Auto Service and Maintainance 5 1 1Auto Service and Maintainance 5 1 2Clothing Store 3 1 2Golf Course 5 1 3Golf Course 3 1 1Total Auto Service n Maint POI 2 Total Clothing Store POI 1 Total Golf Course POI 1 12 rows selected
Thanks in Advance
Saaz