--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements.  See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership.  The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License.  You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

select lstg_format_name, sum(price) as GMV from  test_kylin_fact where lstg_format_name='FP-GTC' group by lstg_format_name order by lstg_format_name

select LSTG_FORMAT_NAME, sum(price)as GMV, count(1) as TRANS_CNT from  test_kylin_fact group by LSTG_FORMAT_NAME order by LSTG_FORMAT_NAME

select test_kylin_fact.lstg_format_name, sum(price) as GMV, count(*) as TRANS_CNT  from  test_kylin_fact group by test_kylin_fact.lstg_format_name order by test_kylin_fact.lstg_format_name

select test_kylin_fact.lstg_format_name,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT from  test_kylin_fact group by test_kylin_fact.lstg_format_name having sum(price)>5000  order by test_kylin_fact.lstg_format_name

select test_kylin_fact.lstg_format_name,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT  from  test_kylin_fact where test_kylin_fact.lstg_format_name is null group by test_kylin_fact.lstg_format_name having sum(price)>5000 and count(*)>72 order by  test_kylin_fact.lstg_format_name

select test_kylin_fact.lstg_format_name,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT  from  test_kylin_fact where test_kylin_fact.lstg_format_name is not null group by test_kylin_fact.lstg_format_name  having sum(price)>5000 or  count(*)>20 order by  test_kylin_fact.lstg_format_name

select test_kylin_fact.lstg_format_name,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT  from  test_kylin_fact where test_kylin_fact.lstg_format_name='FP-GTC' group by test_kylin_fact.lstg_format_name having sum(price)>5000 or count(*)>20 order by  test_kylin_fact.lstg_format_name

select test_kylin_fact.lstg_format_name,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT from  test_kylin_fact where test_kylin_fact.lstg_format_name='FP-GTC' group by test_kylin_fact.lstg_format_name order by  test_kylin_fact.lstg_format_name

select test_cal_dt.week_beg_dt, count(*) as TRANS_CNT from  test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt   group by test_cal_dt.week_beg_dt order by test_cal_dt.week_beg_dt

select test_cal_dt.week_beg_dt,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT from  test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt  where test_kylin_fact.lstg_format_name='FP-GTC'  and  test_cal_dt.week_beg_dt  between DATE '2013-05-01' and DATE '2013-08-01' group by test_cal_dt.week_beg_dt order by test_cal_dt.week_beg_dt

select test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT from  test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt  where test_cal_dt.week_beg_dt  between DATE '2013-05-01' and DATE '2013-08-01' group by test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt having sum(price)>500 order by test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt

select test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT  from  test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt  where  test_cal_dt.week_beg_dt  >= DATE '2013-02-10' group by test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt order by test_kylin_fact.lstg_format_name, test_cal_dt.week_beg_dt 


SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,sum(test_kylin_fact.price) as GMV , count(*) as trans_cnt FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id  AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id group by  test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id where  test_cal_dt.week_beg_dt between DATE '2013-09-01' and DATE '2013-10-01' and test_category_groupings.meta_categ_name='Collectibles' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id where  test_cal_dt.week_beg_dt between DATE '2013-09-01' and DATE '2013-10-01' and test_category_groupings.categ_lvl2_name='Comics' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name  

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id where  test_cal_dt.week_beg_dt between DATE '2013-09-01' and DATE '2013-10-01' and test_category_groupings.meta_categ_name='Collectibles' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name  

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id where  test_cal_dt.week_beg_dt between DATE '2013-09-01' and DATE '2013-10-01' and test_category_groupings.categ_lvl3_name='Other' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_cal_dt.week_beg_dt between DATE '2013-02-01' and DATE '2013-03-01' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_cal_dt.week_beg_dt between DATE '2013-02-01' and DATE '2013-10-01' and site_name='Canada' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_cal_dt.week_beg_dt between DATE '2013-02-01' and DATE '2013-10-01' and site_name='Ebay' and test_category_groupings.categ_lvl3_name='Other' and test_kylin_fact.lstg_format_name='Auction' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name  

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc ,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id INNER JOIN test_seller_type_dim ON test_kylin_fact.slr_segment_cd = test_seller_type_dim.seller_type_cd group by  test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc ,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id INNER JOIN test_seller_type_dim ON test_kylin_fact.slr_segment_cd = test_seller_type_dim.seller_type_cd where test_cal_dt.week_beg_dt between DATE '2013-01-01' and DATE '2013-06-01'  group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc  

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc ,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id INNER JOIN test_seller_type_dim ON test_kylin_fact.slr_segment_cd = test_seller_type_dim.seller_type_cd where test_cal_dt.week_beg_dt between DATE '2013-01-01' and DATE '2013-06-04'  and (test_category_groupings.meta_categ_name='Collectibles' or test_category_groupings.meta_categ_name='Clothing, Shoes & Accessories') and  test_category_groupings.categ_lvl3_name <>'Other' and test_sites.site_name='Ebay' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc  order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc  

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc ,sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id INNER JOIN test_seller_type_dim ON test_kylin_fact.slr_segment_cd = test_seller_type_dim.seller_type_cd where  (test_category_groupings.meta_categ_name='Collectibles' or test_category_groupings.categ_lvl3_name='Dresses')  and test_sites.site_name='Ebay' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,test_seller_type_dim.seller_type_desc 



SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,sum(price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id  AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id group by  test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name 


SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_sites.site_name = '英国' group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id group by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_kylin_fact.seller_id ,test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_kylin_fact.seller_id = 10000002 group by  test_kylin_fact.seller_id ,test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name order by  test_kylin_fact.seller_id ,test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_kylin_fact.seller_id = 10000002 group by  test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name order by test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name ,sum(test_kylin_fact.price) as GMV, count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_kylin_fact.seller_id = 10000002 or test_kylin_fact.lstg_format_name = 'FP-non GTC' group by  test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name order by  test_cal_dt.week_beg_dt ,test_category_groupings.meta_categ_name ,test_category_groupings.categ_lvl2_name ,test_category_groupings.categ_lvl3_name ,test_kylin_fact.lstg_format_name ,test_sites.site_name 

SELECT test_category_groupings.meta_categ_name ,sum(test_kylin_fact.price) as GMV_SUM ,max(test_kylin_fact.price) as GMV_MAX ,min(test_kylin_fact.price) as GMV_MIN ,count(*) as TRANS_CNT FROM test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt INNER JOIN test_category_groupings ON test_kylin_fact.leaf_categ_id = test_category_groupings.leaf_categ_id AND test_kylin_fact.lstg_site_id = test_category_groupings.site_id INNER JOIN test_sites ON test_kylin_fact.lstg_site_id = test_sites.site_id where test_kylin_fact.seller_id = 10000002 or test_kylin_fact.lstg_format_name = 'FP-non GTC' group by  test_category_groupings.meta_categ_name order by test_category_groupings.meta_categ_name

select test_cal_dt.week_beg_dt, sum(test_kylin_fact.price) as GMV , count(*) as TRANS_CNT from  test_kylin_fact INNER JOIN test_cal_dt ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt where (test_kylin_fact.lstg_format_name > '') and ( 	(test_kylin_fact.lstg_format_name='FP-GTC') 	OR 	(test_cal_dt.week_beg_dt  between DATE '2013-05-20' and DATE '2013-05-21') ) and ( 	(test_kylin_fact.lstg_format_name='ABIN') 	OR 	(test_cal_dt.week_beg_dt  between DATE '2013-05-20' and DATE '2013-05-21') ) group by test_cal_dt.week_beg_dt order by test_cal_dt.week_beg_dt 

select lstg_format_name, sum(price) as GMV from  test_kylin_fact where lstg_format_name not in ('FP-GTC', 'ABIN') group by lstg_format_name order by lstg_format_name

select  sum(price) as GMV from  test_kylin_fact 

