欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

davinci所有有关别名,字段名引起的sql语法问题

程序员文章站 2022-05-28 09:27:02
...

 

davinci所有有关别名,字段名引起的sql语法问题,进而引起的邮件截图发送不了的问题都是没有配置字段,别名的引号--英文可省中文必须按照配置来

此配置决定了程序拼接引号方式,不同数据库要不同的引号(单引号,双引号)

clickhouse中文别名双引号,mysql有引号即可,程序中构建的也应如此,英文别名可不加引号,要加就按设置的加  mysql‘ clickhouse“

 

 

正确配置

 

 mysql:

   name: mysql

   desc: mysql

   version:

   driver: com.mysql.jdbc.Driver

   keyword_prefix: 

   keyword_suffix: 

   alias_prefix: \'

   alias_suffix: \'

 

 clickhouse:

   name: clickhouse

   desc: clickhouse

   version:

   driver: ru.yandex.clickhouse.ClickHouseDriver

   keyword_prefix:\"

   keyword_suffix:\"---------------字段双引号

   alias_prefix: \"----------------别名双引号

   alias_suffix: \"

 

 

SELECT pp, sum("注册量") as "sum(当日注册量)" FROM =====================里面需要加双引号因为是中文-------------这些双引号可以确保用中文别名,中文查询字段  

 (SELECT T.dept_one AS "pp", COUNT((CASE WHEN (fun_code = '1011010001' AND server_time = toDate('2019-12-15')) THEN fun_code ELSE NULL END)) AS "注册量"

  FROM (SELECT m.*, s.event_property_code, s.event_property_value FROM cms.daily_new_clientrpt_master m LEFT JOIN cms.daily_new_clientrpt_slave s ON m.event_id = s.event_id) T 

  WHERE server_time = toDate('2019-12-15') GROUP BY T.dept_one)

 TY WHERE 1 = 1 GROUP BY "pp"

 

 

SELECT 

T.dept_one as "部门",

COUNT((

  CASE

    WHEN (fun_code='1011010001' and server_time =toDate($g$)) THEN

  fun_code

  ELSE

   NULL

  end

)) as "当日注册量"

 

FROM  

(SELECT m.*, s.event_property_code,s.event_property_value FROM cms.daily_new_clientrpt_master m LEFT JOIN cms.daily_new_clientrpt_slave s on m.event_id= s.event_id ) T   where  server_time =toDate($g$) GROUP BY T.dept_one ORDER BY "当日注册量" DESC;

 

相关标签: davinci