select 一個結果/另一個結果 from table_name
你上邊寫的那個*難道是多列除多列?
那好像不行吧,被除數別=0哈,要不報錯
『貳』 SQL的查詢語句(除法)
先假設你的表名稱為chuqinqk ,其中遲到是一個int欄位(遲到算1,不遲到算0),那麼: select convert(varchar(5),sum(遲到)/count(*)*100)+'%' as 遲到率from chuqinqk
『叄』 sql 語句除法問題
select a,b,a/b as c from table
where b NOT IN(0)
在語句中避免使用不等於,他會使索引實效,進行全表稍掃描,那樣就不好了,影響速度。
『肆』 SQL如何做除法
這樣:
select
t.[origin-destination],t.[SH/LANE/MOT] /(select count(1) from ['TMS$'] )ASPERCENTAGE
FROM (代碼1) t
group by [origin-destination],t.[SH/LANE/MOT]
having t.[SH/LANE/MOT] /count(*) <= 0.01
註:兩個count都是int,相除會沒有小數部分,所以應該都給轉成帶小數的數。
cast as numeric(10,4) 。
(4)sql除法語句轉換擴展閱讀:
SQL中除法運算的實現
R(X,Y)÷S(Y,Z)的運算用結構化語言SQL 語句可表達為下列形式:
select distinct R.X from R R1
where not exists
(
select S.Y from S
where not exists
(
select * from R R2
where R2.X=R1.X and R2.Y=S.Y
)
)
『伍』 如何用SQL語句表述關系代數中的除法操作
R(A,B)/S(B) 將被除關系R按照除S不包含的屬性A進行分組,查看每個分組a,如果分組a中包含的B屬性值能夠覆蓋S中的B屬性值,則該分組符合查詢條件。
『陸』 sql查詢用到兩個欄位相除,如何讓他保留小數兩位
下面的語句即可:
select
*
from
<你沒說表名哦>
where
c<>round(c)
原理就是判斷這個欄位是否和四捨五入以後的結果相同,不同就有小數。你的資料庫系統如果說round為未知函數,那你可以查一下相應的手冊,看看是不是int等。
『柒』 sql語句 字元相除
用convert函數轉換
『捌』 SQL的查詢語句(除法)有哪些
如下:
select * from table1 where 工資>2500 and 工資<3000 //同上
select 姓名 from table1 where 性別='0' and 工資='4000'
select * from table1 where not 工資= 3200
select * from table1 order by 工資desc //將工資按照降序排列
select * from table1 order by 工資 asc //將工資按照升序排列
select * from table1 where year(出身日期)=1987 //查詢table1 中所有出身在1987的人select * from table1 where name like '%張' /'%張%' /'張%' //查詢1,首位字『張』3,尾位字『張』2,模糊查詢
select * from table1 order by money desc //查詢表1按照工資的降序排列表1 (升序為asc)
select * from table1 where brithday is null //查詢表1 中出身日期為空的人