我有三个整数变量: firstCount , secondCount , thirdCount 。我需要比较它并输出结果。我不擅长SQL,但C#代码是这样的:
if(firstCount == secondCount == thirdCount)
return true;
else
return false;
答案 0 :(得分:4)
单向(2008语法)。
SELECT CAST(CASE
WHEN COUNT(DISTINCT C) = 1 THEN 1
ELSE 0
END AS BIT)
FROM (VALUES (@firstCount),
(@secondCount),
(@thirdCount)) t (C)
答案 1 :(得分:3)
declare @first int
, @second int
, @third int
select @first = 0
, @second = 0
, @third = 0
select case when (@first = @second) AND (@second = @third) THEN 1 ELSE 0 END
答案 2 :(得分:2)
以下是一种方法,但在阅读@ meagar的评论后,我发现这个解决方案更优雅。只是等着他把它变成一个答案......
DECLARE @firstcount INTEGER
DECLARE @secondcount INTEGER
DECLARE @thirdcount INTEGER
SET @firstcount = 1
SET @secondcount = 2
SET @thirdcount = 3
IF @firstcount <> @secondcount SELECT 0
ELSE IF @secondcount <> @thirdcount SELECT 0
ELSE SELECT 1
答案 3 :(得分:1)
你想说如果Firstcount等于第二个计数,secondcount等于第三个计数则返回true。
你可以做到
DECLARE @a INT = 2
DECLARE @b INT = 2
DECLARE @c INT = 2
IF (@a = @b AND @a = @c)
BEGIN
Print('true')
END
ELSE
BEGIN
Print('false')
END
虽然没有区别,但您不需要测试B = C
,因为A = C
完全相同,因为所有3个值都必须相同。
答案 4 :(得分:0)
试试代码,
; /* IE10+ */ background: linear-gradient(to bottom, #fbfbfb 0%,#f4f4f5 100%)