这几天在做sql编译相关的东西, 自己弄了个题目,连资深数据库开发人员都可能会搞错. 以下sql中哪些执行时会报错? (适于所有常见DBMS)
1.
select
distinct col
from
tbl
2.
select
distinct col1,
distinct col2
from
tbl
3.
select
count(distinct col% 10)
from
tbl
4.
select
length(distinct col1% 10)
from
tbl
5.
select
sum(distinct col1% 10),
sum(distinct col1% 9)
from
tbl
6.
select
distinct col1,
count(distinct col2)
from
tbl
7.
select
sum(distinct col1 % 10),
count(distinct col2 % 9)
from
tbl
8.
select
max(distinct substr(col1, 1, 10)),
count(distinct col2 % 9)
from
tbl