1.7 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0. LeetCode中的原题,请参见我之前的博客Set Matrix Zeroes 矩阵赋零.
1.创建基础表 CREATE TABLE num (i INT); INSERT INTO num (i) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2.查询时间范围 SELECT adddate('2015-11-25', numlist.id) AS 'date' FROM ( SELECT n1.i + n10.i * 10 + n100.i * 100 AS id FROM num n1 CROSS JOIN num AS n10 C
在写一个统计查询的 SQL 语句时,需要根据年.月.日分组,但要求返回的字段是日期格式:yyyy年MM月dd日.刚开始我的做法是返回年.月.日,然后再手动拼接年月日,而且还要判断月份和日期是否为个位数,是的话需要在左侧补零.项目经理看了我代码之后,告诉我直接可以在 SQL 中处理.下面是 SQL 语句: SELECT CAST(stats_year AS character varying) || '年' || lpad(CAST(stats_month AS character varying