SQL Convert Rows to Columns and Columns to Rows without using Pivot Functions

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2022
  • In this video we will discuss how to convert rows to columns and vice versa without using pivot functions. Below is the script to create table and data:
    create table emp_compensation (
    emp_id int,
    salary_component_type varchar(20),
    val int
    );
    insert into emp_compensation
    values (1,'salary',10000),(1,'bonus',5000),(1,'hike_percent',10)
    , (2,'salary',15000),(2,'bonus',7000),(2,'hike_percent',8)
    , (3,'salary',12000),(3,'bonus',6000),(3,'hike_percent',7);
    select * from emp_compensation;

ความคิดเห็น • 255

  • @ankitbansal6
    @ankitbansal6  18 วันที่ผ่านมา

    Master the art of SQL with my zero to hero SQL for data analytics course.
    www.namastesql.com/course-detail/think-sql-go-from-zero-to-hero-english

  • @as-youtuber6215
    @as-youtuber6215 2 ปีที่แล้ว +48

    Man you might don't know how much you are helping other people. True gem

  • @lokeshvaishnav218
    @lokeshvaishnav218 ปีที่แล้ว +1

    Man you are an amazing person helping a lot of people

  • @ankush_in_sync5998
    @ankush_in_sync5998 วันที่ผ่านมา

    One of the unique thing Ankit sir does is giving the table script in the description. By this we can copy the script and practice. Thank you.

  • @ratiranjannayak5712
    @ratiranjannayak5712 2 ปีที่แล้ว +3

    Thank you for your video. I have an exact requirement and your video makes it very clear with a proper description and makes it easy to understand. Thank you so much

  • @karthikvb1293
    @karthikvb1293 2 ปีที่แล้ว +1

    Really a great concept, explained very well.

  • @ashutoshpandey1452
    @ashutoshpandey1452 ปีที่แล้ว +1

    this is what I was searching for.. thanks man

  • @bhooshan25
    @bhooshan25 ปีที่แล้ว +1

    Practising from your videos before my interview. Thanks for the videos.

  • @adreamer9999
    @adreamer9999 2 ปีที่แล้ว

    Great video! Excellent step-by-step explanation. Thank you.

  • @nigarmutallimova8461
    @nigarmutallimova8461 7 หลายเดือนก่อน

    This was an awesome tutorial! Very informative without the extra puff. Thank you so much!

    • @ankitbansal6
      @ankitbansal6  7 หลายเดือนก่อน

      Glad it was helpful!

  • @sharu164
    @sharu164 ปีที่แล้ว

    Thanks Ankit for your time on this video 😊 appreciate all your effort

  • @girishggirishg1083
    @girishggirishg1083 ปีที่แล้ว +1

    I got a query related to this, thank you now i got some clarity.

  • @ankushjain4128
    @ankushjain4128 7 หลายเดือนก่อน

    keep doing what you are doing really it is very helpful.

  • @sanchitvaid7017
    @sanchitvaid7017 ปีที่แล้ว +3

    I was asked this question in an interview (US based Health insurance company) but I only knew how to solve it using Pivot function and could not answer it. I wish if I had found this video sooner!

  • @brianducharme3418
    @brianducharme3418 ปีที่แล้ว

    Sir you are brilliant, so much easier then using SQL pivot operator. Thank you kindly.

  • @user-mn4og3ql4x
    @user-mn4og3ql4x 9 หลายเดือนก่อน

    Thank you very much, Sir. The same question I have been asked in the interview. And because I had already watched this video, I could be able to solve this in the interview.

  • @thedatakid1270
    @thedatakid1270 2 ปีที่แล้ว

    Very much helpful video. Ankit sir please upload such more complex query video

  • @Exceltech810
    @Exceltech810 ปีที่แล้ว

    it's hard to see so so clear and easy understanding video. thank you

  • @JosueLopezXIX
    @JosueLopezXIX 2 หลายเดือนก่อน

    Nice video! Thank you.

  • @jaydeeppatidar4189
    @jaydeeppatidar4189 2 ปีที่แล้ว +1

    Your videos has golden content! Just wowwwww!

  • @rakeshgopidi4066
    @rakeshgopidi4066 ปีที่แล้ว

    @Ankit - Awesome very well explained !

  • @pavitrashailaja850
    @pavitrashailaja850 2 ปีที่แล้ว

    Well explained video!

  • @MotivationToMoveForward
    @MotivationToMoveForward ปีที่แล้ว

    It's really awesome video. I have learnt some great insights from this video

  • @milindzuge906
    @milindzuge906 2 ปีที่แล้ว

    Informative content ❣

  • @RAAMASHAAMYC
    @RAAMASHAAMYC หลายเดือนก่อน

    I have been working with SQL for a decade now. Now only I know that we can use 'val' for producing result instead of the field name itself. True Genius.

    • @ankitbansal6
      @ankitbansal6  หลายเดือนก่อน

      val is a column in the table 😊

    • @jececdept.9548
      @jececdept.9548 29 วันที่ผ่านมา

      ​@@ankitbansal6 pls suggest how to study from so many videos..is there any pdf of these available.?

    • @ankitbansal6
      @ankitbansal6  29 วันที่ผ่านมา

      @@jececdept.9548 just solve 1 question at a time everyday

  • @gritmanish
    @gritmanish ปีที่แล้ว

    Thanks for explanation. It was nice

  • @shubhamgoyal3358
    @shubhamgoyal3358 2 ปีที่แล้ว

    Good one ankit, I am watching daily 1-3 video from your channel to prepare for faang

  • @shoaibshaikh8909
    @shoaibshaikh8909 ปีที่แล้ว +7

    Hi ankit, thank you so much for simplifying the concepts. It would be great if you could make similar videos using the sum and case concept solving real interview questions or problems

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว

      I have several videos on my channel using that concept. 😊

  • @georgehall2882
    @georgehall2882 5 หลายเดือนก่อน

    This was great and well explained. Thanks

    • @ankitbansal6
      @ankitbansal6  5 หลายเดือนก่อน

      Glad you enjoyed it!

  • @shilpibiswas3110
    @shilpibiswas3110 8 หลายเดือนก่อน

    Hello ankit sir,
    Truly blessed to come across your superb videos....thank you so much sir and please keep helping is this way by more of ur interview questions on sql, pythons

    • @ankitbansal6
      @ankitbansal6  8 หลายเดือนก่อน

      Keep watching

  • @eel3720
    @eel3720 ปีที่แล้ว

    Great work Ankit so helpful thank you.

  • @CricketLivejavwad
    @CricketLivejavwad 9 วันที่ผ่านมา

    Thank you for the awesome video.I tried to solve this by myself after getting hint by this video and after struggling finally I was able to solve this problem and one more thing I want to tell you this concept is used in my job role also.
    Thanks again sir :)

    • @ankitbansal6
      @ankitbansal6  9 วันที่ผ่านมา +1

      Glad it helped!

    • @CricketLivejavwad
      @CricketLivejavwad 9 วันที่ผ่านมา

      Thank you sir ​@@ankitbansal6

  • @adityaf17
    @adityaf17 ปีที่แล้ว

    This is very helpful!
    Thanks

  • @tupaiadhikari
    @tupaiadhikari ปีที่แล้ว

    Thanks Ankit for the video, we have to use pivot function using pandas for subsequent ml work, but now we can do the data transformation directly in SQL and post which we can directly train the ml model

  • @shubhiverma2571
    @shubhiverma2571 ปีที่แล้ว

    Thankyou so much for this video

  • @kundankumar5520
    @kundankumar5520 ปีที่แล้ว

    True superhero👍

  • @emiliogarza6446
    @emiliogarza6446 2 ปีที่แล้ว

    Really good explanation, great job :)

  • @suketshah7697
    @suketshah7697 2 ปีที่แล้ว +1

    Thanks very well explained...!

  • @ramakumarguntamadugu1299
    @ramakumarguntamadugu1299 4 หลายเดือนก่อน

    very useful 👌👌👍👍

  • @udaykumar-dl6ux
    @udaykumar-dl6ux ปีที่แล้ว

    Thanks a lot sir for explaining in detail.

  • @scrt1111
    @scrt1111 ปีที่แล้ว

    Thank you valuable share

  • @desflan06
    @desflan06 ปีที่แล้ว

    Thank you, this help me a lot.

  • @chronoray8786
    @chronoray8786 ปีที่แล้ว

    So fantastic. Thank you so much. :)

  • @rashmidutta7151
    @rashmidutta7151 2 ปีที่แล้ว

    Hi Ankit, very crisply explained. Can you explain how each row gets created in both the cases.I mean execution of the query. Thanks in advance!!

  • @ashishdukare1313
    @ashishdukare1313 ปีที่แล้ว +1

    Thank you for your efforts : )

  • @surojeetghosh8389
    @surojeetghosh8389 ปีที่แล้ว

    hello sir. thank you for sharing these concepts.its really helpful.sir im an aspiring data analyst and i really want to become good in sql.i know the basics and intermediate concepts.from where should i practice the hard concepts like this which you are teaching?once again thank u.

  • @mallikarjunpatil7553
    @mallikarjunpatil7553 ปีที่แล้ว

    Great session 👍

  • @manishkadam6724
    @manishkadam6724 3 หลายเดือนก่อน

    Thank you so much

  • @mohit231
    @mohit231 2 ปีที่แล้ว +1

    Great video

  • @deepakcl1449
    @deepakcl1449 ปีที่แล้ว

    Thank you so much ! 🙂

  • @MrKingoverall
    @MrKingoverall 11 หลายเดือนก่อน

    Thank you so much sir for your help. 👍👍🙏

    • @ankitbansal6
      @ankitbansal6  11 หลายเดือนก่อน

      Keep watching 💪

  • @user-yp5tj2ce3s
    @user-yp5tj2ce3s 4 หลายเดือนก่อน

    thank you so much

  • @subhojeetlearning
    @subhojeetlearning 11 หลายเดือนก่อน

    Very nicely explained

    • @ankitbansal6
      @ankitbansal6  11 หลายเดือนก่อน

      Keep watching😊

  • @metricsview33
    @metricsview33 8 หลายเดือนก่อน

    excellent

  • @snipezu805
    @snipezu805 2 ปีที่แล้ว

    Thanks friend very helpful

  • @kawshalchettri6614
    @kawshalchettri6614 ปีที่แล้ว +1

    Hello Ankit,
    I bought multiple courses on SQL but finally started to understand by watching your videos. Thank you so much.
    I want to know where can I get more use cases to practice for case statements using sum and other aggregate functions.

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว

      Check out the complex SQL problems playlist

  • @user-rf1gk8gx2x
    @user-rf1gk8gx2x 10 หลายเดือนก่อน +1

    🎯 Key Takeaways for quick navigation:
    00:14 📊 Learn how to convert rows to columns and vice versa in SQL without using pivot functions.
    01:25 🧮 Use SQL case statements to pivot data from rows to columns for specific components.
    04:27 🧾 Practice using case statements with sum for efficient data pivoting in SQL.
    05:28 🔄 Unpivot data by creating a new table using SELECT INTO and then using UNION to achieve the desired format.
    08:18 📚 Mastering case when with sum is crucial for handling data transformations, and it's a valuable skill for interviews and job tasks.
    Made with HARPA AI

  • @raghuramm3297
    @raghuramm3297 8 หลายเดือนก่อน +1

    Hi Ankit, if we have other salary component we have to alter the query . Can we dynamically generate the columns(for each Salary component)without using the pivot function.

  • @garimabatra2658
    @garimabatra2658 2 หลายเดือนก่อน

    Hello Ankit, firstly congratulations for hitting 1lakh subscribers on youtube and gratitude for the resourceful videos. I have one doubt while trying to unpivot the table i am encountering the error msg Undeclared variable : emp_compensation_pivot , how to remove that error. Pls help. Thanks in advance.

  • @Ashu23200
    @Ashu23200 2 หลายเดือนก่อน

    Hi Ankit
    I am learning a lot from you.
    Thank you, Thank you again.
    Please clear my doubt.
    Pasting my query below.
    I tried this method.
    but following both this method and aggregating both ways coming same output
    select
    emp_id,
    sum(case when salary_component_type = 'salary' then val end) as salary,
    sum(case when salary_component_type = 'bonus' then val end) as bonus,
    sum(case when salary_component_type = 'hike_percent' then val end) as hike_percent
    from emp_compensation
    group by emp_id;
    select
    emp_id,
    max(case when salary_component_type = 'salary' then val end) as salary,
    max(case when salary_component_type = 'bonus' then val end) as bonus,
    max(case when salary_component_type = 'hike_percent' then val end) as hike_percent
    from emp_compensation
    group by emp_id;
    how???

    • @ankitbansal6
      @ankitbansal6  2 หลายเดือนก่อน +1

      There is only one not null value in each group. So max min avg all same ..

    • @Ashu23200
      @Ashu23200 2 หลายเดือนก่อน

      @@ankitbansal6 ok

  • @aravindsatheesh4086
    @aravindsatheesh4086 2 ปีที่แล้ว +6

    Nice Video, thank you. I have a doubt. Is there any way that we can dynamically create these columns during pivoting instead of explicitly typing the column values in each sum(case) statement? If we have more unique values and more rows, it might be useful if possible.

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +2

      There is pivot function to do that. I will make a separate video.

  • @hariarayakeel
    @hariarayakeel 2 ปีที่แล้ว

    Thanks a lot Baha’i, very helpful video. I tried this in report which has 200 columns to unpivot and 5 inner joins, finally the script has 2300 lines now (each union has 15 lines). I have used inner joins on each union. Is it the a way to refine the script more!

  • @kanchans3556
    @kanchans3556 5 หลายเดือนก่อน

    Is 'select into' syntax for creating new table worked in MySQL ? I got error

  • @niveditasingh1176
    @niveditasingh1176 2 ปีที่แล้ว +1

    Hi Ankit, Thanks for creating this video . It was really helpful . Can you please create more examples around this.

  • @NaturalPro100
    @NaturalPro100 10 หลายเดือนก่อน

    awesome vide

    • @ankitbansal6
      @ankitbansal6  10 หลายเดือนก่อน

      Glad you enjoyed it

  • @NaveenKumar-fq4sb
    @NaveenKumar-fq4sb ปีที่แล้ว

    super sir make a more interview quations.....

  • @saurabhkhare3315
    @saurabhkhare3315 2 ปีที่แล้ว +2

    Well explained... Please make some videos on path to join Amazon as a Business Intelligence Engineer or Data Engineer.

  • @ankithashetty9133
    @ankithashetty9133 12 วันที่ผ่านมา

    Incase if the rows are way to high how do we dynamically bring them as column names, is there a way to do it? It's not possible to give names individually . In my case I should bring dates as column names from the row.

  • @alex45688
    @alex45688 ปีที่แล้ว

    Thanks for sharing much value , a small request if you can make such more videos
    god bless you

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว +1

      Sure 😊

    • @alex45688
      @alex45688 ปีที่แล้ว

      @@ankitbansal6 People like you are a great help to the society and for new learners, we pray many people support this channel
      Will inform other people also to join this channel

  • @seelamrk
    @seelamrk ปีที่แล้ว

    Thank you . What if I add one more type called Gender that has "Male" or "Female" - we cannot do SUM or any numerical aggregate like MIN/MAX in that case - so how do we solve that?

  • @SachinKumarHS
    @SachinKumarHS 3 หลายเดือนก่อน

    i have also tried this approach using window functions -
    select emp_id, salary, hike_percent, bonus
    from (
    select emp_id, val as salary,
    lead(val) over a as hike_percent,
    lead(val,2) over a as bonus,
    row_number() over a as rn
    from emp_compensation
    window a as (partition by emp_id order by salary_component_type desc)
    ) t
    where rn=1
    Thank you

  • @rutujakelkar2895
    @rutujakelkar2895 ปีที่แล้ว +1

    Hi Ankit, Your videos are helpful to learn SQL in depth, do you have any github repository where you have hosted all your YT questions and solutions ? Or something in text/ blog format ?

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว +1

      I haven't done that yet. Planning that.

  • @girishggirishg1083
    @girishggirishg1083 ปีที่แล้ว

    hi bro actually i tried the same but while doing unpivoting .... "select emp_id, 'salary' as salary_component_type, salary as val from temp" i got an error code 1054: unknown column salary in field list (where i actually want 10000 as output in val column). can u help me with this.

  • @toshitachakraborty4184
    @toshitachakraborty4184 ปีที่แล้ว

    I am a big fan if you Ankit 💓

  • @harshitaggarwal3554
    @harshitaggarwal3554 ปีที่แล้ว +1

    Thanks a lot Ankit it was very helpful. Just one question in case we have multiple column like let's say 10-15 then we need to write 10-15 case statement from row to column and 10-15 union all in case od column to row or do we have any other approach

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว

      Alternatively you can use pivot and unpivot functions.

  • @taniyasaini6830
    @taniyasaini6830 2 ปีที่แล้ว +2

    Very well explained. I just have one question which may sound very basic. How to distinguish between pivoting and unpivoting? i always get confused which one is what

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +1

      Row to column is pivot and reverse in unpivot.

  • @navkarwebstudio7490
    @navkarwebstudio7490 9 หลายเดือนก่อน

    How to pivot If all my columns having date. If sum will work in that case?

  • @vinipowerbi
    @vinipowerbi ปีที่แล้ว +1

    Thank you Ankit for awesome explanation.
    Is there another video to practice this topic?

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว +1

      There are many in this playlist
      Complex SQL Questions for Interview Preparation: th-cam.com/play/PLBTZqjSKn0IeKBQDjLmzisazhqQy4iGkb.html

  • @sujitnayak3072
    @sujitnayak3072 ปีที่แล้ว

    The same query how can we perform if the value has non numeric values.

  • @KukuG28
    @KukuG28 4 หลายเดือนก่อน

    This method is dependent on number of columns. How to make this dynamic like pivot. Pivot automatically takes new column into account whereas this method will require to change query to add every new column. Please help.

  • @atulsharma2789
    @atulsharma2789 2 ปีที่แล้ว

    Hi i have try this example in DB but this is not working it show me error when i use case statement and using then val showing invalid column name please suggest me.

  • @pranauvkumar2692
    @pranauvkumar2692 ปีที่แล้ว

    I could not understand sir we can do it by pivot function right ? can u please explain ?

  • @priyachauhan813
    @priyachauhan813 2 ปีที่แล้ว

    Thanks for your video, but what if I want to unpivot 35 different months columns into row based and 35 quantity columns for the corresponding month into row based.
    This method is not useful fod that, also the unpivot function is not efficient here, query processing times is going more then an hour, could you please suggest any approach for this

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +1

      You have only 2 options. Either use pivot unpivot functions or do like in video.

  • @kartiks792
    @kartiks792 2 ปีที่แล้ว +1

    Hi Ankit great video. Just one doubt can sum function work on string values in the case statement? Example just adding another columns as name and pan no.

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +2

      Yes it works on string.

    • @kartiks792
      @kartiks792 2 ปีที่แล้ว +1

      @@ankitbansal6 thank you for the clarification. 😊

  • @the_cocktail_kudi
    @the_cocktail_kudi ปีที่แล้ว

    What if there are 2 columns example val and expense_amount. So i want 2 colums from 1 row. Salary_val and salary_expense_amount. How to do that?

  • @TheEJAZ88
    @TheEJAZ88 หลายเดือนก่อน

    can this process be used another query where numbers are not involved for pivot

  • @the_class_apart
    @the_class_apart 2 ปีที่แล้ว

    This solved my potential career-ending problem, thanks a lot brother. How can I perform high performance on this when I am working on big data?

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว

      It's optimised technique only.

  • @VARISHROCKS
    @VARISHROCKS 2 ปีที่แล้ว

    Well explained , just a request Please make a video on how to upload DB tables on this Software , it would be a great help from ur end !!

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +1

      You mean you want to load data from files in your system to SQL server right ?

    • @VARISHROCKS
      @VARISHROCKS 2 ปีที่แล้ว

      @@ankitbansal6 YES

  • @NaveenKumar-ig6gn
    @NaveenKumar-ig6gn ปีที่แล้ว +2

    Hi Ankit, i am trying to run the below query in MySQL but getting error like undeclared variable at into emp_compensation_pivot
    Select emp_id
    ,SUM(case when salary_component_type = 'salary' then val end) as Salary
    ,SUM(case WHEN salary_component_type = 'bonus' then val end) as Bonus
    ,SUM(case when salary_component_type = 'hike_percent' then val end) as hike_percent
    into emp_compensation_pivot
    from emp_compensation
    group by emp_id;
    Can you please guide me

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว

      Use create table as instead of into

    • @yatinshekhar787
      @yatinshekhar787 ปีที่แล้ว

      @@ankitbansal6
      sir used create table statement also but it is not working
      is their any other alternative?

  • @idwtv534
    @idwtv534 5 หลายเดือนก่อน

    Does any one know how to solve this problem if we have strings instead of integers. I can't add string right what is the alternative?

  • @shahmaarbaba
    @shahmaarbaba ปีที่แล้ว +1

    what happend when someone enter the new salary component type
    the query set was only the exitsting data when someone enter the new salary component type
    so every time i change the query
    it's not good
    please help me this
    like whenever some add new salary component type how to automatically add val in query

    • @ankitbansal6
      @ankitbansal6  ปีที่แล้ว

      You need to modify the query. Or wrote a dynamic SQL using pl SQL or t SQL

  • @rakeshchaudhary8255
    @rakeshchaudhary8255 2 ปีที่แล้ว

    Hi Ankit, This was very informative. I had the a bit similar usecase in my work but the second column will have 1000s uniques and third columns have respective values. I was able to solve it using Python but the transformation was slow. Is there a way to extend this solution with or without PIVOT for 1000s of unique records ?

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว

      Which means you will have 1000s of column in your o/p?

    • @rakeshchaudhary8255
      @rakeshchaudhary8255 2 ปีที่แล้ว

      @@ankitbansal6 Correct. In short we need to produce the exact same logic for large dataset. how to scale up this solution for 1000 unique values of second column of the original dataset ?

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +1

      @@rakeshchaudhary8255 there is a pivot function. I will make a video on it.

    • @SharukhKhan-pu5sd
      @SharukhKhan-pu5sd ปีที่แล้ว

      @@ankitbansal6 Will search for this .I would like to understand how this can be implemented.

  • @arnabsarkar6159
    @arnabsarkar6159 ปีที่แล้ว

    @ankit How to dynamically pick pivot rows to columns without using pivot function?

  • @srikanthp1643
    @srikanthp1643 ปีที่แล้ว

    sir there is one doubt for me correct me if I'm wrong as you have shown in the video there are only a few rows so we can use the case statement but if there is n number of rows how to do then we can't use the case function right.

  • @sandycool1822
    @sandycool1822 ปีที่แล้ว +1

    Hi Ankit, if possible pls create video on how to do pivoting dynamically. If new entries comes in future it will automatically comes from rows to columns

  • @rajakrishnan8561
    @rajakrishnan8561 4 หลายเดือนก่อน

    Hi Ankit, thank you sharing such a wonderful tip. this solves purpose.. But i have text value in "Val" column. when i use sum function, it shows error invalid digit value 'L'. any idea to group text values

    • @ankitbansal6
      @ankitbansal6  4 หลายเดือนก่อน

      You can use string agg function ..or can use min , max

  • @poorvaagnihotri7104
    @poorvaagnihotri7104 7 วันที่ผ่านมา

    Hi Ankit, Thanks for this explaination. I was asked below question in LatentView Analytics Interview , can you share a optimal solution for that
    Input:-
    class Sub
    A Maths
    B English
    A Social
    B Chemistry
    A Physics
    B Statistics
    A Biology
    B Maths
    A Science
    B Social
    Result:
    Class Sub1 Sub2 Sub3 Sub4 Sub5
    A Science Physics Social Maths Biology
    B English Social Maths Statistics Chemistry

    • @ankitbansal6
      @ankitbansal6  7 วันที่ผ่านมา

      You can use a similar case when statements as explained in video. Just use max or min along with case when.

  • @blackout604
    @blackout604 ปีที่แล้ว

    This is awesome!! Would this syntax work in mysql too?

  • @divyav3827
    @divyav3827 2 ปีที่แล้ว

    Hi Ankit, Nice video, thanks for this one. Is there a video, to convert rows to columns with column name dynamically, instead of explicit mention in the case statement and pivot function.
    Note: Sybase doesn't have Pivot function.

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว

      Sure will look into it 🙂

    • @divyav3827
      @divyav3827 2 ปีที่แล้ว

      Thank you! Looking forward to your video on it

  • @srushtimakhija4429
    @srushtimakhija4429 2 ปีที่แล้ว

    Here you used sum but what if i have varchar values? So I can’t use case with sum in that case, correct?

    • @ankitbansal6
      @ankitbansal6  2 ปีที่แล้ว +1

      You can do min max on varchar instead of sum