如何在不使用IsNULL
的情况下编写以下声明?
Case
When (IsNull(Email_Ind, '') != 'N'
then 'e'
else 'n'
end
这会得到正确的结果吗?
Case
When Email_Ind != 'N' and Email_Ind is not null
then 'e'
else 'n'
end
答案 0 :(得分:3)
您的个案陈述看起来很好。这只是对如何编写它的偏好问题。对我来说,这更容易理解,但对于所有人来说,情况并非如此。
Case When Email_Ind != 'N' or Email_Ind is null then 'e' else 'n' end
答案 1 :(得分:-1)
使用EXCEPT and INTERSECT来做这类事情:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:background="@drawable/border"
android:paddingBottom="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_marginRight="55dp"
android:paddingBottom="5dp">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/fromStationField"
android:completionThreshold="1"
android:hint="From"
android:textAlignment="textStart"
android:gravity="left|start"
android:layout_gravity="left" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toStationField"
android:completionThreshold="1"
android:hint="To"
android:background="@android:color/transparent"
android:paddingRight="4dp"
android:paddingLeft="4dp" />
</LinearLayout>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/imageView"
android:src="@drawable/ic_swap"
android:layout_marginLeft="-55dp"
android:layout_gravity="center_vertical" />
</LinearLayout>
</RelativeLayout>
正如@ypercubeᵀᴹ所建议的那样,这也可行(并且可能是更具语义性的方式来陈述查询):
select case when (select Email_Ind intersect select 'Y') = 1 then 'E' else 'N' end