sql条件查询语句的实例用法
本篇内容主要讲解“sql条件查询语句的实例用法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“sql条件查询语句的实例用法”吧!
复制代码 代码如下:
//创建成绩表createtableresult(stu_idvarchar2(20)notnull,chinanumber(9,2)null,mathnumber(9,2)null,englishnumber(9,2)null);//插入数据insertintoresultvalues('0001',60,20,80);insertintoresultvalues('0002',80,60,80);insertintoresultvalues('0003',20,85,80);select*fromresult;//条件查询selectstu_id,(casewhenchina>80then'优秀'whenchina>=60then'及格'whenchina<60then'不及格'end)as语文,(casewhenmath>80then'优秀'whenmath>=60then'及格'whenmath<60then'不及格'end)as数学,(casewhenenglish>80then'优秀'whenenglish>=60then'及格'whenenglish<60then'不及格'end)as英语fromresult
到此,相信大家对“sql条件查询语句的实例用法”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。