Bitwise Puzzle – SQL in Sixty Seconds 160

Earlier I posted a puzzle SQL Puzzle – SELECT ~ 1 : Guess the Answer, which got over 123 answers. Lots of people said they were not able to believe this puzzle happening in the real world and based on the request, I have made the recent video on the same topic of the bitwise puzzle.

Let me know what you think of this puzzle and solution. A little bit more about Bitwise operators: Bitwise operators perform bit manipulations between two expressions of any of the data types of the integer data type category. Bitwise operators convert two integer values to binary bits, perform the AND, OR, or NOT operation on each bit, producing a result. Then converts the result to an integer.

Let me know if you are interested to know more about this topic like a bitwise puzzle and I will write more blogs as well as create an SQL in Sixty Seconds video.

Here are my few recent videos and I would like to know what is your feedback about them.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

SQL SERVER – ISNUMERIC Function and Interesting Result

1 Comment.Leave new

• Carter Cordingley
April 28, 2021 12:23 am

I used this to find the last business day
(
@st date
)
RETURNS date
AS
BEGIN
DECLARE @results DATE
;with LB as (
Select
day,
case
when datepart(weekday,@st) in(1,2)
then  ~datepart(weekday,@st)
else -1
end
,@st) dd,0 t
union all
Select
day,
case
when datepart(weekday,lb.dd ) in(1,2)
then  ~datepart(weekday,lb.dd )
else -1
end
,lb.dd ),h.hId
from LB
join dbo.Holidays h on h.HolidayDate=LB.dd
)
Select @results = min(dd) from LB
RETURN @results
END