如何通过嵌套计算右连接的所有空值?

时间:2018-08-04 06:28:48

标签: sql

android.support.v4.app.FragmentManager mfFragmentManager = ((AppCompatActivity)mContext).getSupportFragmentManager();
AppointmentBookingDialogFragment appointmentBookingDialogFragment = new AppointmentBookingDialogFragment(mContext,position);
appointmentBookingDialogFragment.show(mfFragmentManager,"appointmentdialog");

1 个答案:

答案 0 :(得分:0)

您需要告诉我们您正在使用哪个DBMS? MySQL或SQL Server?您已经标记了两者!

在SQL Server中:

SELECT COUNT(   CASE
                    WHEN Orders.EmployeeID IS NULL THEN 1
                    ELSE NULL
                END
            )
FROM Orders
    RIGHT JOIN Employees
        ON Orders.EmployeeID = Employees.EmployeeID;

如果将列名传递给COUNT函数,它将不会计算空值,因此,为了计算NULL值,可以使用CASE确定NULL值并使{ {1}}用于对它们进行计数(COUNT),并且还需要确定非NULL值,并使make WHEN Orders.EmployeeID IS NULL THEN 1函数不对它们进行计数(COUNT)。

https://docs.microsoft.com/en-us/sql/t-sql/functions/count-transact-sql?view=sql-server-2017上了解有关ELSE NULL的更多信息