select * from cjgl_cjqxx where cjd in
創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司,提供網(wǎng)站制作、成都網(wǎng)站建設(shè),網(wǎng)頁設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);可快速的進(jìn)行網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,是專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
(
select cjd from
(
select cjd from cjgl_cjqxx where cbrq = to_date('2014-05-06','yyyy-mm-dd') group by cjd
union
select cjd from cjgl_cjqxx where cbrq = to_date('2014-05-07','yyyy-mm-dd') group by cjd
union
select cjd from cjgl_cjqxx where cbrq = to_date('2014-05-08','yyyy-mm-dd') group by cjd
)
group by cjd having count(cjd) = 3;
) ;
試試看。
問一下:是要找連續(xù)三天最大的,還是最大的數(shù)據(jù)是連續(xù)三天的?如果是最大的數(shù)據(jù)連續(xù)三天的
思路這樣,查詢所有reptype最大的那三條WORKDATE信息,并且YESTERDAYWORKINGTIME2,然后將這三條數(shù)據(jù)中max(WORKDATE)-MIN(WORKDATE)=2的reptype的數(shù)據(jù)打印出來。
需要嵌套查詢。
如果是連續(xù)三天的數(shù)據(jù)中最大的那三條思路要變一下。
我的思路是用1~10
減去
除了斷點以外的ID,
然后查找(斷點ID-1)
那一行的記錄。這個腳本具有可擴展性。當(dāng)你取的是100或者其他數(shù)值也可以。我用的數(shù)據(jù)庫是oracle。具體做法:
1
新建一張表B,
為了存全部的1
~10
CREATE
table
B
as
select
ID
FROM
A
where
1=2;
2
向B表中插入1~10,
C表是數(shù)據(jù)庫中任意表要求至少有11行數(shù)據(jù),為了取rownum
insert
into
B
select
rownum
from
C
where
rownum
11;
3
查找斷點
select
*
from
A
where
ID
IN
(select
ID
-1
from
B
where
ID
not
in
(select
ID
from
A)
)
;
這個正則表達(dá)式還真不會寫,期待高手回答。
不過如果急,可以變通下,用個存儲過程實現(xiàn):
創(chuàng)建一個臨時字典表,插入篩選規(guī)則數(shù)據(jù):‘a(chǎn)aa’,'bbb','ccc',,,,,'zzz'
然后通過select語句篩選出包含這些字符串的數(shù)據(jù):
select 字段名 from 表名 a where exists(select * from 臨時表 where a.字段名 like '%'+臨時字段+'%')
或者這樣寫:
select 字段名 from 表名 where regexp_like(字段名,'(a{3}|b{3}|c{3}||d{3}|e{3}|f{3}|g{3}|h{3}|i{3}|j{3}|k{3}|l{3}|m{3}|n{3}|o{3}|p{3}|q{3}|r{3}|s{3}|t{3}|u{3}|v{3})|w{3}|x{3}|y{3}|z{3}')
創(chuàng)建測試表:
create?table?test
(name?varchar2(1),
num?int);
insert?into?test?values?('A',1);
insert?into?test?values?('A',2);
insert?into?test?values?('A',4);
insert?into?test?values?('B',5);
insert?into?test?values?('B',7);
insert?into?test?values?('B',8);
insert?into?test?values?('C',9);
insert?into?test?values?('C',11);
commit;
執(zhí)行:
with?t?as
(select?name,
num,
row_number()?over(partition?by?name?order?by?num?desc)?rn
from?test)
select?s.name,?s.num
from?(select?t2.*
from?t?t1,?t?t2
where?t1.rn?=?t2.rn?-?1
and?t1.num?=?t2.num?+?1
and?t1.rn?=?1
union?all
select?*?from?t?where?rn?=?1)?s
order?by?name,?num
結(jié)果:
你應(yīng)該希望提取的字段只要含有數(shù)字就提出,剔除空和不含數(shù)字的字符串。
select * from table where regexp_substr(check,'[0-9]+') is not null
當(dāng)前題目:c語言fbs函數(shù),fbs函數(shù)
當(dāng)前地址:http://chinadenli.net/article42/heechc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、關(guān)鍵詞優(yōu)化、做網(wǎng)站、網(wǎng)站維護(hù)、自適應(yīng)網(wǎng)站、小程序開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)