‘壹’ 执行sql创建语句,如果执行成功resultset返回什么东西
resultset 顾名思义。是结果集的意思。就是通过sql在数据中执行之后,可以看到的多行数据的集合。返回一个结果集之后,可以通过getString("字段名") 或getString(字段出现的顺序数) 来获得相应的数据。可以通过System.out.println(getString("字段名")) 在后台打印出来或者显示在页面。
‘贰’ 有学生表tb,字段name,subject,result ,怎样写sql语句
selectname,
sum(casewhensubject='语文'thenresultelse0end)as语文,
sum(casewhensubject='数学'thenresultelse0end)as数学,
sum(casewhensubject='物理'thenresultelse0end)as物理
fromtbgroupbyname
‘叁’ sql 怎么写排名 ID RESULT 4 90 3 85 5 85 2 56 1 54 4 第 1 3,5 第2 2 第4 1 第1
select identity(int,1,1) as fid,*,cast('第' as char(10)) as mc into #temp1 from #temp order by result desc
declare @fnum int
declare @fsum int
declare @fflag int
declare @fresult int
declare @fnumstr char(2)
set @fnum=1
set @fsum=(select count(fid) from #temp1)
while @fnum<=@fsum
begin
if @fnum=1
begin
set @fresult=(select result from #temp1 where fid=@fnum)
set @fnumstr=(select cast(@fnum as char(2)))
update #temp1 set mc=ltrim(rtrim(mc))+@fnumstr where fid=@fnum
end
else
begin
set @fflag=(select count(fid) from #temp1 where result=@fresult)
if (@fflag=1 and @fresult>-1) or @fresult=-1
begin
set @fresult=(select result from #temp1 where fid=@fnum)
set @fnumstr=(select cast(@fnum as char(2)))
update #temp1 set mc=ltrim(rtrim(mc))+@fnumstr where fid=@fnum
end
else if @fflag>1
begin
update #temp1 set #temp1.mc=a.mc from (select result,mc from #temp1 where fid=@fnum-1) a where a.result=#temp1.result
set @fresult=-1
set @fnum=@fnum-2+@fflag
end
end
set @fnum=@fnum+1
end
select * from #temp1
drop table #temp1
--把这个数据写入#temp这个表了,你可以根据自己的需要,填写
‘肆’ sql语句中first_result +1 units day - 1 units second是什么意思呢正确写法是怎么写的呢
first_result 你的字段
1 units day一个单位时间
1 units second 一个单位描
不过这明显不是sql语句。反正在那边是无法运行。你从那边找来的
‘伍’ 这个SQL语句哪里不对了
SELECT o1.DATES,COUNT(o1.result) AS "胜",COUNT(o2.result) AS "负"
FROM test1 o1 JOIN test1 o2 ON o1.a = o2.a
WHERE o1.result = '胜' AND o2.result = '负'
GROUP BY o1.DATES
‘陆’ SQL语句怎么写
select D.date,D.WIN as '胜',E.lose as '负'
from
(select date,win from(
SELECT date,
case when result = '胜' then count(result) else 0 end as 'win',
case when result = '负' then count(result) else 0 end as 'lose'
from T3
group by date,result
) C
where win > 0
group by date,C.win,C.lose) D,
(select date,lose from(
SELECT date,
case when result = '胜' then count(result) else 0 end as 'win',
case when result = '负' then count(result) else 0 end as 'lose'
from T3
group by date,result
) C
where lose > 0
group by date,C.win,C.lose) E
where E.date = D.date
-------------------------结果---------------
结果如下
date 胜 负
2007-07-01 00:00:00 2 2
2007-08-01 00:00:00 1 2
‘柒’ 问这个SQL语句该怎样写
/*转化:把B、C列相同的给去掉*/
--建立临时表
create table #result
(
seg_A seg_A_type null,
seg_B seg_B_type null,
seg_C seg_C_type null
)
--找出两个及两个以上相同的值
insert into #result(seg_B,seg_C)
select distinct B,C from table group by B,C having count(1) > 1
--赋值主键(不知道你要的主键是不是也有规律,比如最小的,或者最大的)
update #result set seg_A = b.A from #result a,table b where a.seg_B = b.B and a.seg_C = b.C
--删除B、C列重值
delete table from #result a,table b where a.seg_B = b.B and a.seg_C = b.C
--补入
insert into table (A,B,C)
select seg_A,seg_B,seg_C from #result
--释放临时表
drop table #result
‘捌’ 数据库emp,表中有id和Result两个字段。。。求写SQL语句
selectid,count(Result)fromempwhereid='需要的ID'groupbyResult