1、首先查询业主表中的地址id,不重复显示。
2、然后对t_account标按使用量进行升序排序,默认是升序,asc可以省略。
3、接着对t_account表按使用量进行降序排序。
4、然后通过rownum伪列可以限制查询结果集中返回的行数。
5、最后空值查询——①查询t_pricetable表中maxnum为空的记录;②查询t_pricetable表中maxnum不为空的记录。
oracle中varchar,varchar2,nvarchar,nvarchar2的区别
1.varchar2把所有字符都占两字节处理(一般情况下),varchar只对汉字和全角等字符占两字节,数字,英文字符等都是一个字节;
2.VARCHAR2把空串等同于null处理,而varchar仍按照空串处理;
VARCHAR2把空串等同于null处理
因此, 你那里的
select count(*) from A where nvl(b,'') = ''
和select count(*) from A where nvl(b,'') <> ''
被 等同为
select count(*) from A where nvl(b,null) = null
和select count(*) from A where nvl(b,null) <> null
所以查询不出数据。
oracle中没有空字符串的,只有null,而且判断是否非空只能用is null或is not null,与null的运算,结果仍然是null。
‘’在oralce 就是null值,
你查询下 select count(*) from A where b is not null and trim(b) is null 看看
如果不行,看看b里是否有全角的空格
select count(*) from A where nvl(b,' ') = ' '
select count(*) from A where b is null
select count(*) from A where b is not null