sql非布爾類型的表達式
1. sql多欄位查詢重復數據語句中在應使用條件的上下文(在','附近)中指定了非布爾類型的表達式是怎麼解決
你是sqlserver 庫吧。sqlserver不支持這種寫法,這寫法是oracle支持的,sqlserver多欄位的in就得使用exists,或者 join 等寫法了
select*fromstuda
whereexists(select1from(selectStudentno,SnamefromstudgroupbyStudentno,Snamehavingcount(*)>1)bwherea.Studentno=b.Studentnoanda.Sname=b.Sname)
或者
select*fromstudajoin(selectStudentno,SnamefromstudgroupbyStudentno,Snamehavingcount(*)>1)bona.Studentno=b.Studentnoanda.Sname=b.Sname
有問題追問
2. SQL查詢的問題:在應使用條件的上下文(在 ')' 附近)中指定了非布爾類型的表達式。
1 check約束要求括弧裡面是個bool類型的表達式 把分號去掉
2 各個表建表語句後面的逗號去掉
3 int(20) 不要給int制定列寬
4 後面幾個外鍵建立的時候寫法有誤
3. 【sql】在應使用條件的上下文中指定了非布爾類型的表達式
left join 的語法是,left join 表名 on 條件
你的sql中,只寫出了要關聯的表,但是沒有on條件啊,在後面把條件加上就可以了。
4. SQL查詢問題:在應使用條件的上下文(在 ')' 附近)中指定了非布爾類型的表達式。請問如何解決呢
1、 付款時間=(...)這個就錯了,應該是 付款時間 in(...)
2、第一個Where後面應該是條件,條件應該是一個條件表達式,你這樣寫是錯的
5. SQL語句中IN謂詞前帶兩屬性提示:括弧中在應使用條件的上下文(在 ',' 附近)中指定了非布爾類型的表達式
為什麼要這樣寫呀親,你不要用IN語句。直接 AND SC.cno in (1,2) 就可以了呀
沒有sqlsever的環境 in(a,b)不知道它sql能不能這樣寫 我試了一下postgresql是可以的。
第三行就只有一個逗號。
6. SQL查詢的問題(在應使用條件的上下文(在 ')' 附近)中指定了非布爾類型的表達式。)
1.Having子句後面要跟布爾類型的表達
2.別名branch_avg後的(branch_name,avgbalance)也是多餘的。
修改後:
select branch_name,avgbalance
from (select branch_name,avg(balance) as avgbalance
from account_table
group by branch_name)
as branch_avg
group by branch_name
having max(avgbalance) = sum(avgbalance)
也可以這樣寫:
將平均balance降序排序,第一行就是最大的。
select top 1 branch_name,avgbalance
from (select branch_name,avg(balance) as avgbalance
from account_table
group by branch_name)
as branch_avg
order by avgbalance desc
7. SQL遇到的問題!消息 4145,級別 15,狀態 1 出現了錯誤:非布爾類型表達式是什麼啊求助~~~~
Create rule sex_rule as @sex='男' or @sex='女'
go
exec sp_bindrule 'sex_rule','person.sex'
8. SQL中顯示在使用條件的上下文中指定了非布爾類型的表達式是什麼意思(顯示第三行有語法錯誤)
1.Having子句後面要跟布爾類型的表達 2.別名branch_avg後的(branch_name,avgbalance)也是多餘的。修改後: select branch_name,avgbalance from (select branch_name,avg(balance) as avgbalance from account_table group by branch_name) as branch_avg group by branch_name having max(avgbalance) = sum(avgbalance) 也可以這樣寫:將平均balance降序排序,第一行就是最大的。 select top 1 branch_name,avgbalance from (select branch_name,avg(balance) as avgbalance from account_table group by branch_name) as branch_avg order by avgbalance desc
9. sql中在應使用條件的上下文(在 ',' 附近)中指定了非布爾類型的表達式問題
select t2.customer_name
from customer t1 left join customer t2 on t1.city=t2.city and t1.street=t2.street
where t1.customer_name='smith'
10. SQL編程問題 在應使用條件的上下文(在 'iCurrentStrength' 附近)中指定了非布爾類型的表達式。
where子句,必須是一個布爾判斷表達式,iBudgetedStrength - iCurrentStrength不符合規則。
select count(*)
from Position
where iBudgetedStrength = iCurrentStrength 改成「=」