Oops! Sorry!!

This site doesn't support Internet Explorer. Please use a modern browser like Chrome, Firefox or Edge.

Top 10 SQL Interview Queries | Popular SQL Queries for SQL Interview

+ Q1: Delete duplicate data

drop table if exists cars;

create table cars ( model_id int primary key,

               model_name varchar(100),

               color varchar(100),

               brand varchar(100) );

insert into cars values(1,'Leaf', 'Black', 'Nissan');

insert into cars values(2,'Leaf', 'Black', 'Nissan');

insert into cars values(3,'Model S', 'Black', 'Tesla');

insert into cars values(4,'Model X', 'White', 'Tesla');

insert into cars values(5,'Ioniq 5', 'Black', 'Hyundai');

insert into cars values(6,'Ioniq 5', 'Black', 'Hyundai');

insert into cars values(7,'Ioniq 6', 'White', 'Hyundai');

select * from cars;

delete from cars where MODEL_ID not in(select min(model_id) from cars group by model_name,color);

delete duplicate record from table

by default every method inside public abstract whether you are declaring or not

you can not take concrete method inside interface

Every variable is final

  • public static final int x = 10;

  • public abstract void m1()

  • Defualt method :

              defualt method used inside interface used for declare concrete method in java 8, 


    Override Default method

    • if you want to override defualt implementation you can override by providing your own implementation in implemented class


    default method w.r.t multiple interface

    Usecase may be same defualt method available on mutiple interface

    we can solve the ambiguity problem by overriding the defualt method and calling defualt method from interface using super keyword

    static method inside Interface 

    static method is used for utility purpose in java8 and its called using Interface name