Jonvy

导航

SQL常用语句及其在Postgres 运用

1. limit

限制查询数量,语法 LIMIT行数[OFFSET 偏移量],如果没有偏移量,默认从1开始

如:

select * from t_xml_report limit 10 Offset 5

SQL Server用法:使用TOP关键字 ,例:select  TOP 15 * from T_STOCPF where STOCPF_LINE='8108'

 

2.在字符里插入控制字符,如下,插入GS.

update t_stocpf set stocpf_no_cli=concat('643440300A',chr(29),'000JV') where id_stocpf='888900000231'

3.update多个字段,如下,对reindex执行计划手工reindex后更新信息

update t_reindex set reindex_finishdate,reindex_finishhour,et_reindex_state,reindex_message values('20230929','09054316',1,'OK')
where et_prod='6007' and id_reindex=757

4.Having

Having是对Group by分组之后的数据进行筛选

如:

SELECT department_id,COUNT(*)

FROM employees

GROUP BY department_id

HAVING COUNT(*)>10

第13讲课后问题解答

SELECT d.Department_id,count(*) From (SELECT * from employees where salary>10000) d
GROUP BY d.Department_id
HAVING count(*)>2 ;

 

posted on 2022-11-10 11:06  不亮  阅读(35)  评论(0)    收藏  举报