Bitwise Puzzle – SQL in Sixty Seconds 160

Bitwise Puzzle - SQL in Sixty Seconds 160 160-Bitwise-Puzzle-yt-800x450 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 in Sixty Seconds, SQL Scripts, SQL Server
Previous Post
Neutralize Troublesome SQL Server Indexes – Fun Stories & Demos – Video
Next Post
Query Ignoring CPU Threads – SQL in Sixty Seconds #161

Related Posts

1 Comment. Leave new

  • Carter Cordingley
    April 28, 2021 12:23 am

    I used this to find the last business day
    ALTER FUNCTION [dbo].[LastBusinessDay]
    (
           @st date
    )
    RETURNS date
    AS
    BEGIN
           DECLARE @results DATE
           ;with LB as (
                         Select
                                      dateadd(
                                             day,
                                             case
                                                    when datepart(weekday,@st) in(1,2)
                                                           then  ~datepart(weekday,@st) 
                                                           else -1
                                             end  
                                             ,@st) dd,0 t
                  union all
                  Select
                         dateadd(
                               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

    Reply

Leave a Reply