SQL Interview Questions Part 54 | WALMART Interview Question & Answer | Frequently Purchased Pairs

Поделиться
HTML-код
  • Опубликовано: 2 ноя 2024

Комментарии • 26

  • @andreanlobo7373
    @andreanlobo7373 Год назад +3

    I've liked your explanation. Thanks

  • @SatheeshPK-r6p
    @SatheeshPK-r6p 15 дней назад +1

    nice explanation

    • @ItJunction4all
      @ItJunction4all  15 дней назад

      I am glad you found it helpful! Thank you !

  • @ashwinkadam6404
    @ashwinkadam6404 2 года назад +7

    Hi Sir,
    I didnt get the line A.product_name < B.product_name
    can you explain the thought process
    this will clear my doubt
    Thanks for the Video!

    • @sarvesht7299
      @sarvesht7299 2 года назад +1

      I too have this doubt.. please clarify

    • @p26p2006
      @p26p2006 2 года назад +2

      Same question from my side bcoz product name is not a numerical value so how can we use less than operator here

    • @ItJunction4all
      @ItJunction4all  2 года назад +19

      Hi ...when you do not add A.product_name < B.product_name condition , you will get below combination of product1 and product2 as shown below.
      apple apple
      banana apple
      soya milk apple
      apple banana
      banana banana
      soya milk banana
      instant oatmeal instant oatmeal
      soya milk instant oatmeal
      apple soya milk
      banana soya milk
      instant oatmeal soya milk
      soya milk soya milk
      1.
      From the above combination, we do not require below combination :
      (apple apple) , (banana banana) , (instant oatmeal instant oatmeal) , ( soya milk soya milk) as it does not make any sense
      2.
      From the below combination, we require only one combination as it means the same :
      (banana apple) and (apple banana)
      (banana soya milk) and (soya milk milk )
      (instant oatmeal soya milk) and (soya milk instant oatmeal)
      etc..
      In order to remove both above combinations, we will have to use A.product_name < B.product_name .
      What this query will do ?
      ProductName being string datatype, it will compare the ASCII value of first character of both the product. In case ASCII value of first character is same , it will check and compare second character and so on.
      In case of (apple apple ) combination, ASCII value will always be same ...so this combination will be ruled out as ( A.product_name < B.product_name )
      In case of
      (banana apple) and (apple banana) , only one pair will be satisfied other will be ruled out.
      This way we will be able to reject unwanted combinations of product1 and product2.
      I hope I am able to explain you. If you still find any doubts, u can comment. I will try to make you understand.
      Please like my video and subscribe my channel if you have not done so. This will help my channel to grow.

    • @sarvesht7299
      @sarvesht7299 2 года назад

      @@ItJunction4all great explanation. Thanks bro

    • @ashwinkadam6404
      @ashwinkadam6404 2 года назад

      @@ItJunction4all Thank you Sir ♥️💯🙏

  • @brieparmar
    @brieparmar 2 года назад

    "when you first open up soft soft..."