如何使用行不可见和可见的条件 [英] How to use condition for row invisible and visible
问题描述
SELECT uniquiID,
CountryFlag,
EventImage
,CONVERT(varchar(50),StartDate)作为StartDate
,CONVERT(varchar(50),EndDate)作为EndDate
,EventName
,描述
,CountryCode
,备注
,旗帜
来自TradefairData<
我尝试过什么:
和我的标志栏值是 - Null
0
1 >
Null
0
1
然后我想知道如何使用案例时flag = 1然后当flag = 0时第3和第6行不可见然后所有行可见其他所有行都可见请帮助我
uniquiID是我的uniqueId专栏
你的问题不清楚...
正如我在对问题的评论,没有这样的功能来显示/隐藏干净的T-SQL中的行。获取所有数据并仅显示符合某些条件的数据的方法是使用报告工具。但是(!)如果你想用flag = 0或null
获取数据,你可以使用这样的东西:
SELECT *
FROM YourTableName
WHERE 标志= 0 或标志< span class =code-keyword> IS NULL
详情请见:
WHERE(Transact-SQL)| Microsoft Docs [ ^ ]
SELECT示例(Transact-SQL)| Microsoft Docs [ ^ ]
SELECT(Transact-SQL)| Microsoft Docs [ ^ ]
这里是标志为1然后显示记录谁有标志1而标志0显示记录谁有标志0并且没有任何要传递的标志然后显示所有值
声明 @ flag 位</ span>
if ( @ flag != 0 或 @ flag != 1)
begin
SELECT uniquiID,CountryFlag,EventImage, CONVERT ( varchar ( 50 ),StartDate ) as StartDate
, CONVERT ( varchar ( 50 ),EndDate) as EndDate,EventName,Description,CountryCode,Remark,Flag
FROM TradefairData
结束
其他
开始
SELECT uniquiID,CountryFlag,EventImage, CONVERT ( varchar ( 50 ),StartDate) as StartDate
, CONVERT ( varchar ( 50 ),EndDate) as EndDate,EventName,Description,CountryCode,Remark,Flag
FROM TradefairData 其中标志= @ flage
端跨度>
SELECT uniquiID,
CountryFlag,
EventImage
,CONVERT(varchar(50), StartDate) as StartDate
,CONVERT(varchar(50), EndDate) as EndDate
,EventName
,Description
,CountryCode
,Remark
,Flag
FROM TradefairData <
What I have tried:
and my flag column value is - Null
0
1
Null
0
1
Then i Want to Know how to Use case when flag=1 then 3rd and 6th row invisible when flag=0 then all row visible else all row visible please help me
uniquiID is my uniqueId Column
Your question is not clear...
As i stated in the comment to the question, there's no such functionality to show/hide rows in clean T-SQL. The way to fetch all data and display only data which meets some criteria is to use reporting tools. But (!) if you want to fetch data withflag = 0 or null
, you can use something like this:
SELECT * FROM YourTableName WHERE Flag = 0 OR Flag IS NULL
For further details, please see:
WHERE (Transact-SQL) | Microsoft Docs[^]
SELECT Examples (Transact-SQL) | Microsoft Docs[^]
SELECT (Transact-SQL) | Microsoft Docs[^]
Here is where flag is 1 then show record who have flag 1 and flag 0 show record who have flag 0 and nothing to pass in flag then show all value
Declare @flag bit if(@flag !=0 or @flag !=1 ) begin SELECT uniquiID,CountryFlag,EventImage,CONVERT(varchar(50), StartDate) as StartDate ,CONVERT(varchar(50), EndDate) as EndDate,EventName,Description,CountryCode,Remark,Flag FROM TradefairData end else begin SELECT uniquiID,CountryFlag,EventImage,CONVERT(varchar(50), StartDate) as StartDate ,CONVERT(varchar(50), EndDate) as EndDate,EventName,Description,CountryCode,Remark,Flag FROM TradefairData where flag=@flage end
这篇关于如何使用行不可见和可见的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!