gpt4 book ai didi

sql - Case 表达式,如何从 Then 子句中的列中获取值

转载 作者:行者123 更新时间:2023-12-04 03:08:33 25 4
gpt4 key购买 nike

如果以下条件为真,我需要从 Mortgage_Type 列中获取 THEN 的值。

  1. Mortgage_Type 和 Category 是同一个表,Equipment 来自另一个表。

Tables are joining using Item_No. I need to find the Mortgage_Type of each item. I have 20+ Mortgage_Types if Category is main and Equipment is null then should display relevant Mortgage_Type

 when SUM (Mortgage_Type)is not null and SUM (Equipment)is null and
sum(Category) ='M' THEN “value from Mortgage_Type column”

最佳答案

只需给出列名:

CASE 
WHEN (Mortgage_Type)is not null and (Equipment)is null and (Category) ='M'
THEN Mortgage_Type
ELSE <other value>
END

关于sql - Case 表达式,如何从 Then 子句中的列中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47009588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com