2017-07-06 208 views
-4

我需要一個請求,顯示信用額度最小的客戶的名字和姓氏 - 在不住在日本,巴西或意大利的已婚女性中。如何編寫SQL查詢?

圖:

enter image description here

+0

請閱讀[問]。你有什麼嘗試,爲什麼沒有工作? – HoneyBadger

+0

大多數人在這裏想要格式化文本,而不是圖像。 – jarlh

回答

0

這將給所有不在 '日本', '巴西' 或 '意大利'),

Select C.Cust_first_name,C.Cust_Last_name from Customers C 
      Inner Join Countries C1 
       on C.Country_Id=C1.Country_Id 
     Where C1.Country_Name Not in('Japan', 'Brazil' or 'Italy') 
     and 
    C.Cust_Credit_Limit=(Select Min(Cust_Credit_Limit) From from Customers C) 

如果我們轉換問題代碼的人那將是上面的代碼, 腳本將返回不在('日本','巴西'或'意大利')中的人員的姓名和姓氏並且在整個客戶庫中具有最低工資。

+0

cust_credit_limit在Customers表中 – Ulugbek

+0

Customers表中存在所有必要的行:婚姻狀態-cust_marital_status,性別 - cust_gender,country - country_id – Ulugbek

0

選擇頂部1 *從客戶Ç

內部聯接

( SELECT MIN(CUST_CREDIT_LIMIT)從客戶C1

內在上C1.Country_id = C1.Country_id加入國家CT

其中CT.Country_Name不在('Japan','Brazil','Italy')

) C2上的C2.cust_credit_limit = C.cust_credit_limit