有一些sql 是必须要做笔记的!!
1 2 3 4 5 6 | select CONCAT(unix_timestamp(), "-" ,id, "-" ,name) as aa,age from workers; //连接字段 select substr(concat( "0000000" ,id),8,2) from workers //从第八位开始截2位 select right(concat( "0000000" ,id),3) from workers //截取右边5位 截取左边5位改成left |
1 2 3 4 5 6 7 8 9 10 11 12 | SELECT substr(comm, 1, locate( '(' , comm) - 1) FROM groupcomm_sz WHERE comm LIKE '%(%' set @row=0; SELECT module, machine, time , @row:=@row+1 rownum FROM total_freq_ctrl order by module,machine, time desc limit 10; |
1 | select a.city,a.comm,a.num,a.rank from ( select a.city,a.comm,a.num,row_number() over (PARTITION by a.city ORDER BY a.num desc ) as rank from ( select city,comm, count ( distinct urls) as num from salehouse_tmp where tosite = 'fang' and length(comm)>1 and length(comm)<12 and length(city)>1 group by city,comm)a)a where a.rank <7; |
1 | select a.urls from ( select urls from anjuke_info where date like '201707%' and type = 'SaleHouse' group by urls)a left outer join ( select urls from rank_salehouse where web = 'anjuke' group by urls)b on (a.urls = b.urls) where b.urls is null ; |
UPDATE wuhan_houseList SET includeTime=DATE_ADD(includeTime,INTERVAL -1 DAY) 更新日期字段(字段为Date类型) 减去一天
select company,zone,num,rank from ( select b.company,b.zone,b.num,@rownum:=@rownum+1 , if(@pdept=b.zone,@rank:=@rank+1,@rank:=1) as rank, @pdept:=b.zone from ( select company,zone,num from km_data order by zone asc ,num desc ) b ,(select @rownum :=0 , @pdept := null ,@rank:=0) a ) result
select company,zone,site,num,rank from ( select b.company,b.zone,b.site,b.num,@rownum:=@rownum+1 , if(@pdept=b.zone and @aa=b.site,@rank:=@rank+1,@rank:=1) as rank, @pdept:=b.zone,@aa:=b.site from ( select company,zone,site,num from xinya_data_week where day = '2017-11-22' and tag = 'ZoneOnline' order by zone asc ,site asc,num desc ) b ,(select @rownum :=0 , @pdept := null , @aa := null ,@rank:=0) a ) result
根据2个字段排序
结果:
{$where:"this._id!=this.keys"} mongo 查询不等于
select zone,street,comm,towards,floors,floor,room,total,area from tmp_lianjia_1 as a where a.room <> '' and 2> (select count(*) from tmp_lianjia_1 where comm = a.comm and room = a.room and total < a.total ) order by a.comm ,a.total ; 分组算前2名
转载注明出处
如果本文对你有帮助,请帮忙啦~~
打开支付宝首页搜“522901509”领红包,领到大红包的小伙伴赶紧使用哦!
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· C# 13 中的新增功能实操
· Vue3封装支持Base64导出的电子签名组件
· 万字长文详解Text-to-SQL
· Ollama本地部署大模型总结
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(4)