- 1、本文档共10页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
SQL语句题解析
在成绩表中,效率60分为不及格,大于60分为及格,大于80分为优秀,请用一条SQL语句查询。
答:设有成绩表Scores 包含字段ScoreId Score
查询语句如下:
Select 成绩=case
When score between(0 and 59) then ‘不及格’
When score between(60 and 79) then ‘及格’
When score between(80 and 100) then ‘优秀’
Else ‘无效成绩’
End
From Score
请用SQL语句查处当天所有记录.
答: select * from tb_send where datediff(day,sendTime, getdate())=0
sql查询,表table(id,lastUpdateDate);使用一条sql语句查出最近一次的修改时间
答:select top 1 lastUpdateDate from [table] order by lastUpdateDate desc
游标的声明与使用,如何判断记录已到达最末尾
declare @myCur Cursor
declare mySet Cursor for
select * from 表名
set @muCur=mySet
open mySet
fetch next from mySet
while @@FETCH_STATUS=0
begin
fetch next from mySet
end
close mySet
deallocate mySet
看表写SQL
Id 1 自动增长,主键 Name Accp Tel 1111111111 Datetime 2008-1-1 查询出时间在2008-1-1到2009-3-3的所有信息
更新id=8的name为你的姓名,tel为你的电话号码
插入一行数据
答:1)select * from 表 where Datetime=2008-1-1 and Datetime=2009-3-3
2)select name as 姓名,tel as 电话号码 from 表 where id=8
3)insert into 表(name,tel,datetime) values(‘ss’,’111111111’,’2009-01-01’)
1. 查询表中stuAge字段有重复值的数据:
例:
输出结果如下:
答:
select * from stuinfo
where stuAge in
(
select stuAge from stuinfo
group by stuAge having count(*)1
)
2.用 table2中科目余额更新table1中的科目余额,不在table2中出现的科目不更新。
Update table1
set 科目余额 = table2.科目余额 from table2
where table1.科目= table2.科目
6. 查询表中中间的一行数据:
输出:
答:
select * from
(select 行号=row_number() over (order by stuno),* from stuinfo ) temptable
where 行号=(select round(count(*)/2.0,0) from stuinfo)Productid saleName Saleprice Enployee 2 2 200 M 1 5 300 N 3 1 450 M 4 3 500 N Sale
Productid saleName Saleprice Enployee 2 2 200 M 1 5 300 N 3 1 450 M 4 3 500 N
问:
是否可以对product标的数据进行删除,如何操作
答:delete from Sale where Productid=2
Delete from Product where Productid=2
将Sale表中Priductid为2的产品价格更新为Product表中的Price
答:update Sale set Saleprice=Price from Product join Sale on Sale. Productid= Product.Productid wher
文档评论(0)