select24结果,select252
oracle select 语句的结果是随机的吗
查询语句-select * from table; select * from table where 条件1=数值 and 条件2=数值; select * from table where id in (select id from table);两表关联 select a.a,b.b,c.c from table1 a,table2 b,table3 c where a.id1=b.id2; 插入语句-insert into table (字段1,字段2,字段3,……) values (数值1,数值2,数值3,……); 更新语句-update 表名 set 数值 where=id = 1; 添加列语句-alter table 表名 add (列名1 类型1,列名2 类型2,列名3 类型3,……); 查询随机20条记录-select * from( select * from emp order by dbms_random.value) where rownum = 10; 修改列类型-alter table 表名 modify (列名1 类型1,列名2 类型2,列名3 类型3,……); 删除列语句-alter table 表名 drop column 列名s; 显示查询时间-set timing on; 删除表语句-deltet table 表名; 清空表数据-truncate table 表名; 修改列名 - ALTER TABLE emp RENAME COLUMN comm TO newa; 集合查询(无重复):select * from table_name union select * from table_name; 集合查询(有重复):select * from table_name union all select * from table_name; 差 集 查 询:select * from table_name minus select * from table_name; -------------------------------------------------------------------------------- 运行脚本-start d:\文件名.sql; 编辑脚本-edit d:\文件名.sql; 另存为脚本-spool d:\文件.sql; select * from emp; spool off; 分页显示-set pagesize 页数; 行数显示-set linesize 行数; 创建用户-create user 用户名 identified by 密码;(需要SYS/SYSTEM权限才能建立用户) 赋予权限-grant resource to 用户名;(建表权限) 赋予查询权限-grant select on emp to 用户名; 赋予修改权限-grant update on emp to 用户名; 赋予所有访问权限-grant all on emp to 用户名; -------------------------------------------------------- 收回查询权限-revoke select on emp from 用户名; 传递权限-grant select on emp to 用户名2 with grant option; 账户锁定- creata profile 名称 limit failed_login_attcmpts 输入次数限制 password_lock_time 锁定天数; ------------------------------DBA权限登录 alter user 想要锁定的用户名 profile 名称; ------------------------------DBA权限登录解锁用户锁定-alter user 用户名 account unlock; 定期修改密码-create profile 名字 limit password_life_time 天数 password_grace_time 宽限天数; 切换用户-conn system/密码; 更改密码-password 用户名; 删除用户-drop user 用户名 cascade(删除用户及用户建立的所有表); 查询同样结构两表中的不同数据-select * from emp_tmp where empno not in(select empno from emp); select * from v$session; select * from v$version; 定义函数: ---------函数说明 函数是计算数字平方; FUNCTION y2 (inx2 number) return number is Result number(2); begin Result := inx2*inx2; return(Result); end y2; ---------函数说明 函数是输入汉字然后输出拼音; FUNCTION HZ (inputStr in VARCHAR2) RETURN VARCHAR2 iS outputStr varchar2(10); BEGIN SELECT c_spell INTO outputStr FROM BASE$CHINESE WHERE C_WORD = inputStr; RETURN outputStr; END hz; ----------函数说明 函数是计算累加自然月; FUNCTION month (inmonth number, inaddmonth number) return varchar2 is Result varchar2(6); begin Result :=substr(to_char(add_months(to_date(inmonth,'yyyymm'),inaddmonth),'yyyymmdd'),1,6); return(Result); end month; select to_char(add_months(trunc(sysdate),-1),'yyyymmdd') from dual;--取上个月的日期; select to_char((sysdate-30),'yyyymmdd') from dual; ---去当前日期前30天日期; ORACLE 随机数 DBMS_RANDOM.VALUE(low IN NUMBER,high IN NUMBER) RETURN NUMBER; select round(dbms_random.value(x,x)) from dual; ORACLE 取当前时间并按毫秒计算 select systimestamp from dual; select * from cda_datasource---中继表aiy
请帮忙写SQL语句!谢谢!
actiontime 为datetime格式 ,success 为 int 记录(1/0), 考虑如下思路, 其他的自己考虑一下,就可以的
SELECT CONVERT(char(10), actiontime, 120) AS Day, DATEPART(hh, actiontime) AS Hour,
SUM(success) AS SumSuccess, ABS(SUM(1 - CAST(success AS int))) AS SumFailure,
COUNT(success) AS SumGross, Cast(SUM(success) as money)/Cast(COUNT(success)AS money)
AS SuccessRate into #temp1
FROM table1
WHERE (actiontime = Begindate) AND (actiontime = Enddate)
GROUP BY CONVERT(char(10), actiontime, 120), DATEPART(hh, actiontime)
ORDER BY CONVERT(char(10), actiontime, 120), DATEPART(hh, actiontime)
success 为 varchar 记录(成功/失败)时,可修改一下 Sum(case success when '成功' then 1 else 0 end
select * into #temp2 from (select distinct day #temp1) a,(select 1 hour union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9 union
select 10 union select 11 ……union select 24) b
select a.day,b.hour,isnull(a.SumSuccess,0),isnull(a.SumFailure,0),isnull(SumGross,0),isnull(SuccessRate,0)
from (select 1 hour union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9 union
select 10 union select 11 ……union select 24) b,#temp2 a
where b.hour *= a.hour and a.day = b.day
语句都给你写到这份上了, 你不能自己修改啊,…… 那里自己改,想要多少小时自己改上面b括号
VB算24点的函数,急~150分
楼主可能更需要一个可以灵活应用的函数吧
根据楼上的启发,整理成如下这个,楼主只需要复制到程序中,引用函数s24就可以了,比如打印结果:Print s24(1,2,3,4)
Private Function s24(ByVal n1 As Single, ByVal n2 As Single, ByVal n3 As Single, ByVal n4 As Single) As String
Dim i As Integer, j As Integer
Dim a As Single, b As Single, c As Single, d As Single
Dim s() As String
Dim Num As Boolean
If n1 * n2 * n3 * n4 1 Then s24 = "本程序只对正整数有效!": Exit Function
For j = 1 To 30
Select Case j
Case 1
For i = 1 To 1
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a + b + c + d = 24 Then
s24 = a "+" b "+" c "+" d "=24"
Num = True
Exit For
End If
Next i
Case 2
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a + b + c - d = 24 Then
s24 = a "+" b "+" c "-" d "=24"
Num = True
Exit For
End If
Next i
Case 3
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b + c + d = 24 Then
s24 = a "*" b "+" c "+" d "=24"
Num = True
Exit For
End If
Next i
Case 4
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b + c - d = 24 Then
s24 = a "*" b "+" c "-" d "=24"
Num = True
Exit For
End If
Next i
Case 5
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b * c + d = 24 Then
s24 = a "*" b "*" c "+" d "=24"
Num = True
Exit For
End If
Next i
Case 6
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b * c - d = 24 Then
s24 = a "*" b "*" c "-" d "=24"
Num = True
Exit For
End If
Next i
Case 7
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b * c * d = 24 Then
s24 = a "*" b "*" c "*" d "=24"
Num = True
Exit For
End If
Next i
Case 8
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b + c * d = 24 Then
s24 = a "*" b "+" c "*" d "=24"
Num = True
Exit For
End If
Next i
Case 9
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b - c * d = 24 Then
s24 = a "*" b "-" c "*" d "=24"
Num = True
Exit For
End If
Next i
Case 10
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a / b + c + d = 24 Then
s24 = a "/" b "+" c "+" d "=24"
Num = True
Exit For
End If
Next i
Case 11
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b / c + d = 24 Then
s24 = a "*" b "/" c "+" d "=24"
Num = True
Exit For
End If
Next i
Case 12
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b / c - d = 24 Then
s24 = a "*" b "/" c "-" d "=24"
Num = True
Exit For
End If
Next i
Case 13
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b * c / d = 24 Then
s24 = a "*" b "*" c "/" d "=24"
Num = True
Exit For
End If
Next i
Case 14
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * b / c / d = 24 Then
s24 = a "*" b "/" c "/" d "=24"
Num = True
Exit For
End If
Next i
Case 15
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b) * c / d = 24 Then
s24 = "(" a "+" b ")*" c "/" d "=24"
Num = True
Exit For
End If
Next i
Case 16
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b) * c * d = 24 Then
s24 = "(" a "+" b ")*" c "*" d "=24"
Num = True
Exit For
End If
Next i
Case 17
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b) * (c + d) = 24 Then
s24 = "(" a "+" b ")*(" c "+" d ")=24"
Num = True
Exit For
End If
Next i
Case 18
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b) * (c - d) = 24 Then
s24 = "(" a "+" b ")*(" c "-" d ")=24"
Num = True
Exit For
End If
Next i
Case 19
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a - b) * (c - d) = 24 Then
s24 = "(" a "-" b ")*(" c "-" d ")=24"
Num = True
Exit For
End If
Next i
Case 20
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a - b) * c / d = 24 Then
s24 = "(" a "-" b ")*" c "/" d "=24"
Num = True
Exit For
End If
Next i
Case 21
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a - b) * c * d = 24 Then
s24 = "(" a "-" b ")*" c "*" d "=24"
Num = True
Exit For
End If
Next i
Case 22
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b + c) * d = 24 Then
s24 = "(" a "+" b "+" c ")*" d "=24"
Num = True
Exit For
End If
Next i
Case 23
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b + c) / d = 24 Then
s24 = "(" a "+" b "+" c ")/" d "=24"
Num = True
Exit For
End If
Next i
Case 24
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If (a + b - c) * d = 24 Then
s24 = "(" a "+" b "-" c ")*" d "=24"
Num = True
Exit For
End If
Next i
Case 25
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * (b + c) + d = 24 Then
s24 = a "*(" b "+" c ")+" d "=24"
Num = True
Exit For
End If
Next i
Case 26
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * (b - c) + d = 24 Then
s24 = a "*(" b "-" c ")+" d "=24"
Num = True
Exit For
End If
Next i
Case 27
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * (b + c) - d = 24 Then
s24 = a "*(" b "+" c ")-" d "=24"
Num = True
Exit For
End If
Next i
Case 28
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a * (b - c) - d = 24 Then
s24 = a "*(" b "-" c ")-" d "=24"
Num = True
Exit For
End If
Next i
Case 29
For i = 1 To 24
s = Split(Kind(i, n1, n2, n3, n4), " "): a = Val(Trim(s(0))): b = Val(Trim(s(1))): c = Val(Trim(s(2))): d = Val(Trim(s(3)))
If a + (b + c) / d = 24 Then
s24 = a "+(" b "+" c ")/" d "=24"
Num = True
Exit For
End If
Next i
Case 30
s24 = "无解"
Num = True
End Select
If Num = True Then Exit For
Next j
End Function
Private Function Kind(i As Integer, n1 As Single, n2 As Single, n3 As Single, n4 As Single) As String
Dim a As Single, b As Single, c As Single, d As Single
Select Case i
Case 1
a = n1: b = n2: c = n3: d = n4
Case 2
a = n1: b = n2: d = n3: c = n4
Case 3
a = n1: c = n2: b = n3: d = n4
Case 4
a = n1: c = n2: d = n3: b = n4
Case 5
a = n1: d = n2: b = n3: c = n4
Case 6
a = n1: d = n2: c = n3: b = n4
Case 7
b = n1: a = n2: c = n3: d = n4
Case 8
b = n1: a = n2: d = n3: c = n4
Case 9
b = n1: c = n2: a = n3: d = n4
Case 10
b = n1: c = n2: d = n3: a = n4
Case 11
b = n1: d = n2: a = n3: c = n4
Case 12
b = n1: d = n2: c = n3: a = n4
Case 13
c = n1: a = n2: b = n3: d = n4
Case 14
c = n1: a = n2: d = n3: b = n4
Case 15
c = n1: b = n2: a = n3: d = n4
Case 16
c = n1: b = n2: d = n3: a = n4
Case 17
c = n1: d = n2: a = n3: b = n4
Case 18
c = n1: d = n2: b = n3: a = n4
Case 19
d = n1: a = n2: b = n3: c = n4
Case 20
d = n1: a = n2: c = n3: b = n4
Case 21
d = n1: b = n2: a = n3: c = n4
Case 22
d = n1: b = n2: c = n3: a = n4
Case 23
d = n1: c = n2: a = n3: b = n4
Case 24
d = n1: c = n2: b = n3: a = n4
End Select
Kind = a " " b " " c " " d
End Function
sql= "select top 24 * from table" 现在我想把这30条记录分成3组,每组8条,最下面是分页:显示如下:
selelct top 每页显示的数量 from 表名 where 主键 not in (select top (当前页数-1)*每页显示的数量 主键 from 表名)
sql查询,select语句中时间查询
方法:to_char() 函数
select?to_char(data,'yyyy-MM-dd?HH24:MI')?from?table_name;
orcale里有两个时间字段,如何通过SELECT查询出来A字段
select?*?from?表名?where?AB+1
这样就行了,oracle时间字段+1就是+1天,也就是24小时,自己执行一遍下边语句就知道了
select?sysdate,sysdate+1?from?dual