C

@creswahab1403

Intermediate Query 4

SQL
3 years ago
-- Query 9: --Find the top 2 accounts with the maximum number of unique patients on a monthly basis. ---Note: Prefer the account if with the least value in case of same number of unique patients --Table Structure: create table patient_logs

Intermediate Queries 3

SQL
3 years ago
/*-- Query 7: --From the weather table, fetch all the records when London had extremely cold temperature for 3 consecutive days or more. --Note: Weather is considered to be extremely cold then its temperature is less than zero. --Table Structure: create table weather (

Intermediate Queries 2

SQL
3 years ago
/*---Query 4: --From the doctors table, fetch the details of doctors who work in the same hospital but in different speciality. --Table Structure: create table doctors ( id int primary key, name varchar(50) not null,

Intermediate Queries

SQL
3 years ago
/*-- Query 1: --Write a SQL query to fetch all the duplicate records from a table. --Tables Structure: create table users ( user_id int primary key, user_name varchar(30) not null, email varchar(50));

ipl matches

SQL
3 years ago
create table teams ( team_code varchar(10), team_name varchar(40) ); insert into teams values ('RCB', 'Royal Challengers Bangalore'); insert into teams values ('MI', 'Mumbai Indians'); insert into teams values ('CSK', 'Chennai Super Kings'); insert into teams values ('DC', 'Delhi Capitals');

SourceVsTarget

SQL
3 years ago
CREATE TABLE source ( id int, name varchar(1) ); CREATE TABLE target ( id int,

comments_and_translations

SQL
3 years ago
--Write an SQL query to display the correct message (meaningful message) from the input --comments_and_translation table. */ create table comments_and_translation ( id int, comments varchar(100), translation varchar(100) );

tree node

SQL
3 years ago
create table tree(id integer primary key, p_id integer); insert into tree(id, p_id) values(1,null), (2,1), (3,1), (4,2), (5,2);

RowToColumn

SQL
3 years ago
create table emp_input ( id int, name varchar(40) ); insert into emp_input values (1, 'Emp1'); insert into emp_input values (2, 'Emp2'); insert into emp_input values (3, 'Emp3'); insert into emp_input values (4, 'Emp4'); insert into emp_input values (5, 'Emp5');

Cumulative Distance

SQL
3 years ago
/*-->> Problem Statement: Suppose you have a car travelling certain distance and the data is presented as follows - Day 1 - 50 km Day 2 - 100 km Day 3 - 200 km Now the distance is a cumulative sum as in row2 = (kms travelled on that day + row1 kms). How should I get the table in the form of kms travelled by the car on a given day and not the sum of the total distance?*/

Delete Duplicate Data

SQL
3 years ago
----- Scenario 1: Data duplicated based on SOME of the columns -- Requirement: Delete duplicate data from cars table. Duplicate record is identified based on the model and brand name. create table if not exists cars ( id int, model varchar(50), brand varchar(40), color varchar(30),

Window Function Part 2

SQL
3 years ago
CREATE TABLE product ( product_category varchar(255), brand varchar(255), product_name varchar(255), price int ); INSERT INTO product VALUES ('Phone', 'Apple', 'iPhone 12 Pro Max', 1300),

WIndow Function Part 1

SQL
3 years ago
create table employee ( emp_ID int , emp_NAME varchar(50) , DEPT_NAME varchar(50) , SALARY int); insert into employee values(101, 'Mohan', 'Admin', 4000); insert into employee values(102, 'Rajkumar', 'HR', 3000); insert into employee values(103, 'Akbar', 'IT', 4000); insert into employee values(104, 'Dorvin', 'Finance', 6500);

With Clause

SQL
3 years ago
create table emp ( emp_ID int , emp_NAME varchar(50) , SALARY int); insert into emp values(101, 'Mohan', 40000); insert into emp values(102, 'James', 50000); insert into emp values(103, 'Robin', 60000); insert into emp values(104, 'Carol', 70000); insert into emp values(105, 'Alice', 80000);