SQL DATETIME×ֶαȽÏ
±ÈÈçÓиö±íÆäÖÐÓÐ3¸ödatetime×ֶΣ¬Ò»°ãÀ´ËµÆäÖÐÓиödatetime×ֶεÄÖµ»á±ÈÆäËû2¸ö´ó£¨Ð޸ĺóÈÕÆÚ£©£¬ÄÇÔõôÕÒ³öÕâÌõ¼Ç¼£¿
來數據說Ã÷°É
...........
select * from TB where dt1>dt2 and dt1>dt3
union all
select * from TB where dt2>dt1 and dt2>dt3
union all
select * from TB where dt3>dt1 and dt3>dt1
±È½ÏÁ½¸öÈÕÆÚµÄ²î£º
ÓÃ datediff()
SQL code:
select * from TB where dt1>dt2 and dt1>dt3
union all
select * from TB where dt2>dt1 and dt2>dt3
union all
select * from TB where dt3>dt1 and dt3>dt1
ÕÒ³ö¼Ç¼»¹ÊÇÕÒ³ö×Ö¶Î?
DATEDIFF ( datepart , startdate , enddate )
SQL code:
create table #test
(dt1 datetime,
dt2 datetime,
dt3 datetime)
insert #test
select '20100110','20091221','20121212' union all
select '20091221','20121212','20100110' union all
select '20121212','20091221','20100110'
select
case when dt1>dt2 and dt1>dt3 then dt1 else null end,
case when dt2>dt1 and dt2>dt3 then dt2 else null end,
case when dt3>dt2 and dt3>dt1 then dt3 else null end
from #test
Ïà¹ØÎÊ´ð£º
´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽ
XML code:
<folder state="unchecked" label="È«²¿">
¡¡¡¡ <folder state="unchecked&qu ......
ÎÒÊÇÔÚtoadÖÐÊäÈë϶Îsql
declare
TYPE test_rec IS record(
code varchar(10),
name varchar(30)
);
v_book test_rec;
......
±í
id bh
1 10
2 11
3 12
4 15
5 16
6 22
7 25
8 26
9 27
10 28
½«bh°´Á¬Ðø·Ö¶Î³öÀ´·µ»Ø×Ö·û´®£º
10~12£¬15~16£¬22£¬25~28
SQL code:
declare @t tabl ......
select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001'
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......
µÚÒ»¾ä:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm
join jh on ht.htbh=jh.hth
and ht.htbh not like'del%' and ht. ......