幾個SQL語句 備忘

2022-05-03 15:15:15 字數 1454 閱讀 4704

1.三漲停 select biao1.**,biao1.名稱 from biao1,biao2,biao3 where (biao1.漲幅+ biao2.漲幅+biao3.漲幅)>0.27 and (biao1.**

= biao2.**) and  (biao2.** = biao3.**) and not exists (select * from biaoxg where **=biao1.**)

2.二漲停

select biao1.**,biao1.名稱 from biao1,biao2 where (biao1.漲幅+ biao2.漲幅)>0.18 and (biao1.** = biao2.**) 

and not exists (select * from biaoxg where **=biao1.**)

3.一漲停

select biao1.**,biao1.名稱 from biao1 where biao1.漲幅》0.09 and not exists (select * from biaoxg where **

=biao1.**)

4.跌停再 漲停 select biao1.**,biao1.名稱 from biao1,biao2 where biao1.漲幅》0.09 and  biao2.漲幅<-0.09 and (biao1.** = biao2.

**)  

5.錘子 select biao1.**,biao1.名稱 from biao1 where biao1.今開=biao1.最高 and biao1.最新》biao1.最低 and ((biao1.最新-

biao1.最低)/biao1.最低)>0.03

select biao2.**,biao2.名稱 from biao2 where biao2.今開=biao2.最高 and biao2.最新》biao2.最低 and ((biao2.最新-

biao2.最低)/biao2.最低)>0.03

select biao3.**,biao3.名稱 from biao3 where biao3.今開=biao3.最高 and biao3.最新》biao3.最低 and ((biao3.最新-

biao3.最低)/biao3.最低)>0.03

select biao4.**,biao4.名稱 from biao4 where biao4.今開=biao4.最高 and biao4.最新》biao4.最低 and ((biao4.最新-

biao4.最低)/biao4.最低)>0.03

6. select t2.a1 as a11 ,t2.a2 as a22, t2.a3 as a33 ,t2.a4 as a44,t2.a6 as a66,t1.a1 as b1 from xg as t1 left join (select a2,a1,a3,a4,a6 from hqlsz where a1='''+ rdate[0]+''' ) as t2 on t2.a2=t1.a2  order by t1.a1 desc

SQL語句備忘

rank 排序 每個分組進行單獨排名,相同名次的會佔位,比如兩個第二名,就沒有第三名了,直接到第四名 select fenxiaoid,price,rank over 使用rank 進行排名 partition by fenxiaoid 使用fenxiaoid進行分組 order by price ...

sql語句備忘

1.對一張表分類查詢,同時還需要另一張表的字段 select a.kindid,a.scoreall,b.kindname from select kindid,cast cast sum abs score as decimal 100 as decimal 18,2 as scoreall fr...

sql語句備忘(dba)

user tab comments 表注釋 user col comments 表字段注釋 以上兩個只能獲取自己使用者的表的注釋資訊,如果要訪問自己能夠訪問的其他使用者的表,則需要使用 all tab comments 表注釋 all col comments 表字段注釋 當然,如果有dba許可權,...