关于sql的查询语句 情景如下:宿舍里有4人间,也有6人间,但不是每个寝室都住满了人,每个床位都有一个编号(不管住没住人),住了人就对应一个学生的学号,没住人学号那一栏就为空。现在要 查询房间只住2个人的房间有哪些,而且那些房间住了哪些人,哪些床位空着???怎么用sql语句查询???? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 宿舍表:编号 床位数床位表:编号 宿舍 学号只住两人的房间:select 宿舍 from 床位表 where 学号 is not null group by 宿舍 having count(1)=2空床位:select * from 床位表 where 学号 is null 额……其实这张表很简单好吧,我还是把你说的表结构贴出来吧create table chuangwei (cwcode varchar primary key,xh varchar,) --只住两人的房间:select substr(cwcode,1,5) 宿舍 from chuangwei where xh is not null group by substr(cwcode,1,5) having count(1)=2;--空床位:select * from chuangwei where xh is null; 求推Oracle经典书籍!!!!!!! 遇到一个很棘手的问题。。请教高人, 关于oo4o操作错误 oracle 存储过程 数据库字符集zhs16cgb231280,导出时用us7ascii导出,如何再导回去! 谁有oracle8.05的下载地址,100分相求。。。 如何写这个UPDATE更新语句?? 关于Procedure里Create table的问题 哪位大哥有《Oracle 8 初学者指南》英文版?急 请教!关于CLOB??? 高手来啊,不懂啊!~ 那样大哥帮我解决一下 oracle 表空间导入问题?
编号 床位数床位表:
编号 宿舍 学号只住两人的房间:
select 宿舍 from 床位表 where 学号 is not null group by 宿舍 having count(1)=2空床位:select * from 床位表 where 学号 is null
好吧,我还是把你说的表结构贴出来吧
create table chuangwei (
cwcode varchar primary key,
xh varchar,
)
--只住两人的房间:
select substr(cwcode,1,5) 宿舍 from chuangwei where xh is not null group by substr(cwcode,1,5) having count(1)=2;--空床位:
select * from chuangwei where xh is null;