select hits,count(hits) as count,CONCAT(ROUND(count(hits)/(select count(*) from table ) *100,2),'','%') as per from table group by hits having hits is not null order by count desc
## 加flag字段,取出两表不匹配的值
select a.*,b.flag from table as a left join
(select *,'1' flag fromtable) as b
on a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3
where flag is null
## 查询两个字段的去重数据
select count(distinct(concat(col1,col2))) from table
-- 刷新SQL表
refresh table table
select * from table
-- 查看databricks下所有的databases和tables
SHOW (DATABASES | SCHEMAS) [LIKE 'pattern']
SHOW TABLES [(FROM | IN) db_name] [LIKE 'pattern']
SHOW DATABASES
-- oracle 转换日期格式,substr
select TO_CHAR(NOTIF_DT, 'YYYY/MM/DD' ) NOTIF_DT_1 from table where substr(TO_CHAR(NOTIF_DT, 'YYYY/MM/DD' ),1,7)='2020/01'
to_char(current_date, 'YYYYMMDD')