1、***************************************************************************************
sql 代码
- select b.id,b.prod_name,sum(aa) as w1,sum(bb) as w2,sum(cc) as w3,sum(dd) as w4,sum(ee) as w5
- from (
- select a.id,a.prod_name,
- case a.iid when 1 then storeCount1 else 0 end as aa,
- case a.iid when 2 then storeCount1 else 0 end as bb,
- case a.iid when 3 then storeCount1 else 0 end as cc,
- case a.iid when 4 then storeCount1 else 0 end as dd,
- case a.iid when 5 then storeCount1 else 0 end as ee
- from (
- SELECT p.id,i.id as iid,p.prod_name,count(s.id) as storeCount1
- FROM BIZ_PROD_DISTRIBUTION d inner join
- BIZ_PROD_DISTRIBUTION_ITEM di on d.id=di.main_id inner join
- dim_store s on s.id=d.store_id inner join
- dim_dict_item i on i.id=s.store_type inner join
- dim_product p on p.id=di.prod_id
- where d.cate_type='1' and s.is_closed='1'
- group by p.prod_name,i.id,i.item_name,p.id) a
- ) b
- group by b.id,b.prod_name
2、***************************************************************************************
sql 代码
- select sum(g1.a1) as w1,sum(g1.a2) as w2,sum(g1.a3) as w3,sum(g1.a4) as w4,sum(g1.a5) as w5,
- sum(g1.b1) as s1,sum(g1.b2) as s2,sum(g1.b3) as s3,sum(g1.b4) as s4,sum(g1.b5) as s5
- from
-
- (select
-
- case h1.id when '1' then h1.storeTotal ELSE 0 end as a1,
- case h1.id when '2' then h1.storeTotal ELSE 0 end as a2,
- case h1.id when '3' then h1.storeTotal ELSE 0 end as a3,
- case h1.id when '4' then h1.storeTotal ELSE 0 end as a4,
- case h1.id when '5' then h1.storeTotal ELSE 0 end as a5,
-
- case h1.id when '1' then h1.callTotal ELSE 0 end as b1,
- case h1.id when '2' then h1.callTotal ELSE 0 end as b2,
- case h1.id when '3' then h1.callTotal ELSE 0 end as b3,
- case h1.id when '4' then h1.callTotal ELSE 0 end as b4,
- case h1.id when '5' then h1.callTotal ELSE 0 end as b5
-
- from
- (select i.id,x2.storeTotal,x3.callTotal
- from dim_dict_item i inner join
-
- (select s.store_type,count(s.id) as storeTotal
- from dim_store s
- where s.usage_flag='1' and s.is_closed='1'
- group by store_type)x2
-
- on i.id=x2.store_type
- inner join
-
- (select s.store_type,count(distinct c.STORE_ID) as callTotal
- from dim_store s
- inner join
- CALL_PLAN_ITEM c ON s.ID = c.STORE_ID
- where s.usage_flag='1' and s.is_closed='1'
- group by store_type)x3
-
- on x2.store_type=x3.store_type)h1)g1
3、*******************************************************************************************************************************
sql 代码
- select b.id,b.prod_name_en,sum(aa) as w1,sum(bb) as w2,sum(cc) as w3,sum(dd) as w4,sum(ee) as w5
- from (
- select a.id,a.prod_name_en,
- case a.iid when 1 then storeCount1 else 0 end as aa,
- case a.iid when 2 then storeCount1 else 0 end as bb,
- case a.iid when 3 then storeCount1 else 0 end as cc,
- case a.iid when 4 then storeCount1 else 0 end as dd,
- case a.iid when 5 then storeCount1 else 0 end as ee
- from (
- SELECT p.id,i.id as iid,p.prod_name_en,count(s.id) as storeCount1
- FROM BIZ_PROD_DISTRIBUTION d inner join
- BIZ_PROD_DISTRIBUTION_ITEM di on d.id=di.main_id inner join
- dim_store s on s.id=d.store_id inner join
- dim_dict_item i on i.id=s.store_type inner join
- dim_product p on p.id=di.prod_id
- inner join dim_geography g ON s.geo_id = g.id
- inner join dim_geography g1 ON g.parent_geography_id = g1.id
- where d.cate_type='2' and s.is_closed='1' and d.usage_flag='1' and s.usage_flag='1'
-
- group by p.prod_name_en,i.id,i.item_name,p.id) a
- ) b
- group by b.id,b.prod_name_en
4、***********************************************************************************************************************
sql 代码
- select b.id,b.prod_name_en,sum(aa) as w1,sum(bb) as w2,sum(cc) as w3,sum(dd) as w4,sum(ee) as w5
- from (
- select a.id,a.prod_name_en,
- case a.iid when 1 then storeCount1 else 0 end as aa,
- case a.iid when 2 then storeCount1 else 0 end as bb,
- case a.iid when 3 then storeCount1 else 0 end as cc,
- case a.iid when 4 then storeCount1 else 0 end as dd,
- case a.iid when 5 then storeCount1 else 0 end as ee
- from (
- SELECT p.id,i.id as iid,p.prod_name_en,count(s.id) as storeCount1
- FROM BIZ_PROD_DISTRIBUTION d inner join
- BIZ_PROD_DISTRIBUTION_ITEM di on d.id=di.main_id inner join
- dim_store s on s.id=d.store_id inner join
- dim_dict_item i on i.id=s.store_type inner join
- dim_product p on p.id=di.prod_id
- inner join dim_geography g ON s.geo_id = g.id
- inner join dim_geography g1 ON g.parent_geography_id = g1.id
- where d.cate_type='2' and s.is_closed='1' and d.usage_flag='1' and s.usage_flag='1'
- and $P!{queryString}
- group by p.prod_name_en,i.id,i.item_name,p.id) a
- ) b
- group by b.id,b.prod_name_en
5、**********************************************************************************************************************
sql 代码
- select b.id,b.prod_name_en,sum(aa) as w1,sum(bb) as w2,sum(cc) as w3,sum(dd) as w4,sum(ee) as w5
- from (
- select a.id,a.prod_name_en,
- case a.iid when 1 then storeCount1 else 0 end as aa,
- case a.iid when 2 then storeCount1 else 0 end as bb,
- case a.iid when 3 then storeCount1 else 0 end as cc,
- case a.iid when 4 then storeCount1 else 0 end as dd,
- case a.iid when 5 then storeCount1 else 0 end as ee
- from (
- SELECT p.id,i.id as iid,p.prod_name_en,count(s.id) as storeCount1
- FROM BIZ_PROD_DISTRIBUTION d inner join
- BIZ_PROD_DISTRIBUTION_ITEM di on d.id=di.main_id inner join
- dim_store s on s.id=d.store_id inner join
- dim_dict_item i on i.id=s.store_type inner join
- dim_product p on p.id=di.prod_id
- inner join dim_geography g ON s.geo_id = g.id
- inner join dim_geography g1 ON g.parent_geography_id = g1.id
- where d.cate_type='2' and s.is_closed='1' and d.usage_flag='1' and s.usage_flag='1'
- and $P!{queryString}
- group by p.prod_name_en,i.id,i.item_name,p.id) a
- ) b
- group by b.id,b.prod_name_en
6、****************************************************************************************************************
sql 代码
- select b.id,b.prod_name_en,sum(aa) as w1,sum(bb) as w2,sum(cc) as w3,sum(dd) as w4,sum(ee) as w5
- from (
- select a.id,a.prod_name_en,
- case a.iid when 1 then storeCount1 else 0 end as aa,
- case a.iid when 2 then storeCount1 else 0 end as bb,
- case a.iid when 3 then storeCount1 else 0 end as cc,
- case a.iid when 4 then storeCount1 else 0 end as dd,
- case a.iid when 5 then storeCount1 else 0 end as ee
- from (
- SELECT p.id,i.id as iid,p.prod_name_en,count(s.id) as storeCount1
- FROM BIZ_PROD_DISTRIBUTION d inner join
- BIZ_PROD_DISTRIBUTION_ITEM di on d.id=di.main_id inner join
- dim_store s on s.id=d.store_id inner join
- dim_dict_item i on i.id=s.store_type inner join
- dim_product p on p.id=di.prod_id
- inner join dim_geography g ON s.geo_id = g.id
- inner join dim_geography g1 ON g.parent_geography_id = g1.id
- where d.cate_type='1' and s.is_closed='1' and d.usage_flag='1' and s.usage_flag='1'
- and $P!{queryString}
- group by p.prod_name_en,i.id,i.item_name,p.id) a
- ) b
- group by b.id,b.prod_name_en
分享到:
相关推荐
“工具”标签暗示这是一个软件工具,可能是独立的应用程序或者插件,用户可以通过界面交互或者命令行来使用,以完成SQL语句的整理工作。 压缩包子文件的文件名称列表中: 1. ObjString.dll:这是一个动态链接库...
sqllice是一款专为解决SQL代码格式混乱问题而设计的工具,它能够帮助开发人员快速、高效地整理SQL脚本,使其更符合编程规范,提高代码可读性和团队协作效率。无论你是使用Java、Python、C#还是其他语言进行开发,...
SQL语句格式整理器是一款非常实用的工具,它专门针对SQL查询语句的排版混乱问题,通过自动化处理,帮助用户快速将杂乱无章的SQL代码转化为整洁、易读的格式。这样的工具在数据库管理和开发过程中尤为重要,因为它...
本文将基于"oracle常用sql整理"的主题,深入探讨Oracle SQL的一些核心概念、语句及其实用技巧,适合初级到中级水平的学习者。 一、SQL基础 SQL是标准化的查询语言,分为DDL(Data Definition Language)、DML(Data...
SQL跟踪后,用该工具能够快速整理出整洁的SQL,减少人工的复制、帖贴
自制SQL文整理,非开源,非完整,写得很挫,有使用时限,强烈不建议下载
### 一般SQL语句优化整理 #### 概述 在数据库操作中,SQL查询语句是数据检索的核心,其性能直接影响到应用系统的响应时间和资源消耗。对于一般的SQL语句优化,不仅能够提升查询效率,还能改善用户体验。本文将对...
在《SQL》语句整理中,我们涉及了数据库的创建与删除、表的创建与数据操作、查询语句以及聚合函数等核心概念。 首先,创建数据库是数据库管理的基础。在SQL Server 2005中,可以使用`CREATE DATABASE`语句来创建新...
SQL格式整理工具,而且还可以把SQL语句转换成VB DELPHI C# JAVA里面用的格式
标题中的“SQL数据库整理工具”指的是专门用于管理和优化SQL Server数据库的应用程序,这些工具通常包含一系列功能,旨在提升数据库性能,确保数据的准确性和一致性。SQL Server是Microsoft开发的一款关系型数据库...
根据给定的文件信息,我们可以理解为这是一篇关于SQL语句的文章或教程。尽管描述和部分内容提供的信息有限,但我们可以基于标题“刚刚整理的SQL语句”来展开一些重要的SQL知识点,帮助读者更好地理解和掌握SQL的基础...
sql语句整理 sql增删改查 更新数据记录 删除数据记录
"经典SQL查询整理"这个资源聚焦于SQL面试中的常见问题,旨在帮助用户提升SQL技能,更好地应对工作或学习中的挑战。 首先,SQL的核心功能包括以下几点: 1. **数据查询**:SQL的SELECT语句是其最基础也是最重要的...
在SQL面试中,掌握核心概念和技术至关重要。这里我们将深入探讨SQL、Oracle、MySQL以及SQL Server等数据库相关的知识点,这些内容都是面试中常见的考察点。 1. SQL基础: - 数据库概念:理解关系型数据库的基本...
SQL(Structured Query Language)是用于...以上只是SQL知识体系中的一部分,实际的“SQL整理”文件可能还会包含更深入的理论知识、实战技巧、案例分析等内容,对于理解和掌握SQL这一重要的数据库语言有着极大的帮助。
DBA日常维护SQL整理,涵盖操作系统、存储、数据库各个层面
在SQL中,日期处理是常见的操作,尤其是在数据分析和报表生成时。这里我们详细讨论了几个重要的SQL日期函数,这些函数在处理日期和时间数据时非常有用。 1. **getdate()**:这个函数返回当前系统的日期和时间,格式...
Exec SQL整理提供了一种嵌入式SQL语言,能够弥补SQL语言实现复杂应用方面的不足,并提供了预编译方法、嵌入式SQL的一般形式、SQL通信区、主变量和游标查询等功能,使得数据库编程更加高效和灵活。
SQL的核心功能之一就是查询数据。通过SELECT语句,我们可以从数据库中获取所需的信息。基本语法如下: ```sql SELECT column1, column2, ... FROM table_name; ``` 例如,从`employees`表中选择`name`和`salary`两列...