Display Duplicate of a Column | Ep-4 | Top 20 SQL Interview Questions | GeeksforGeeks

Поділитися
Вставка
  • Опубліковано 26 лис 2024

КОМЕНТАРІ • 25

  • @theguynexttoyou
    @theguynexttoyou 3 роки тому +24

    2:58 *just a simple correction*
    We can't use WHERE clause with AGGREGATE Function that's why we are using HAVING clause.

  • @sudheer2682
    @sudheer2682 Рік тому +1

    Good Bro...I was breaking my head with different ways of coding, you have given me a jump start. I appreciate it.....Keep GOING!!!!!!!

  • @YogithaHN-z1c
    @YogithaHN-z1c 6 днів тому

    awesome explaination

  • @divakarkumarjha1171
    @divakarkumarjha1171 4 роки тому +1

    Your concept is really good

  • @ishwarmore3814
    @ishwarmore3814 2 роки тому +4

    2:54 Whenever we have aggregate function we cannot have WHERE clause on that aggregate function so we used HAVING clause.

  • @balajisundar9867
    @balajisundar9867 9 місяців тому +1

    --.Finding duplicates records
    select emp_name, count(*)
    from employee
    group by emp_name
    HAVING count(*) > 1
    -- Scenario: If the Table contains multiple columns where only emp_name is duplicate, but rest of the values are unique.
    --Using Windows function
    select * from (
    select emp_name,
    ROW_NUMBER() OVER(PARTITION by emp_name) rn
    from Employee)
    where rn > 1

  • @adwaydandwate
    @adwaydandwate 6 місяців тому

    Thank you.
    I would like to know the query for below question pls:
    Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.

    • @g.v.snitin8825
      @g.v.snitin8825 Місяць тому

      SELECT CITY,LENGTH(CITY)
      FROM STATION
      ORDER BY LENGTH(CITY),CITY
      LIMIT 1;
      SELECT CITY,LENGTH(CITY)
      FROM STATION
      ORDER BY LENGTH(CITY) DESC,CITY
      LIMIT 1;

  • @Suresh_Shivarathri
    @Suresh_Shivarathri 5 років тому +2

    Nice. Please upload on faq SQL queries

  • @mayanksingh7814
    @mayanksingh7814 5 місяців тому

    select ename from (
    select ename, count(ename) as cnt
    from table
    group by 1) t
    where cnt > 1

  • @praveenj3112
    @praveenj3112 5 років тому +1

    It's good . solve as many questions as possible

    • @3sh66
      @3sh66 5 років тому

      Thanks for the support .Plzz do like share and subscribe

  • @GeekCoders
    @GeekCoders 3 роки тому +2

    It is not mandatory to use Having clause with group by

    • @theguynexttoyou
      @theguynexttoyou 3 роки тому +1

      Yes! He meant we can't use WHERE clause with AGGREGATE functions.

  • @Vinod-dd2vc
    @Vinod-dd2vc 9 місяців тому

    Superb...

  • @sandeshrane5136
    @sandeshrane5136 5 років тому +3

    👍

  • @rrl1919
    @rrl1919 4 роки тому

    Best Thanks

  • @gauravmishra8782
    @gauravmishra8782 Рік тому

    done

  • @ritumehta2655
    @ritumehta2655 Рік тому

    how to display the values in the decreasing order of frequencies?

    • @anonymousape
      @anonymousape Рік тому

      just add "desc" in the last line that is: order by count(*) desc

  • @basavaraj2065
    @basavaraj2065 Рік тому +1

    Can anyone share the all sql queries in one file ?

  • @malliarjun5250
    @malliarjun5250 4 роки тому +1

    You shouldn't tell that whenever we are using group by you shouldn't use where we can use "where" clause alang with group by.we can say that whenever we are using aggregate function to filter the aggregated value should use "having" clause
    before "group by" clause we can use where clause but after group by we can't use group by

  • @nfp613
    @nfp613 Рік тому

    Class = clause :D

  • @malliarjun5250
    @malliarjun5250 4 роки тому +20

    You shouldn't tell that whenever we are using group by you shouldn't use where we can use "where" clause alang with group by.we can say that whenever we are using aggregate function to filter the aggregated value should use "having" clause
    before "group by" clause we can use where clause but after group by we can't use group by