随笔分类 -  sql server

学习累计
摘要:access:select top (10) * from table1 where 1=1db2:select column from table where 1=1 fetch first 10 rows onlymysql:select * from table1 where 1=1 limi... 阅读全文
posted @ 2014-04-14 18:04 sunshine_qqq 阅读(1190) 评论(0) 推荐(0)
摘要:where和having子句都可以实现过滤记录的功能,但他们的用法还是有一些区别的,看一例子:用group by和having子句联合来查出不重复的记录,sql如下:select uid,email,count(*) as ct from `edm_user081217` GROUP BY email然后看这个,就容易理解了select uid,email,count(*) as ct from `edm_user081217` GROUP BY email HAVING ct > 1先用group by 对email进行分组,在用having来过滤大于1的,这样查找出来的就是重复的记录 阅读全文
posted @ 2014-04-04 18:14 sunshine_qqq 阅读(296) 评论(0) 推荐(0)