Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
New
Create table D( D_id int primary key, D_name varchar (20) not null, D_age int check(d_age>23), D_doj date not null, D_specialist varchar(15), D_city varchar(20) not null, D_salary money not null); Insert into d values (101,'Satish',29,'12.09.2018','cardiologist ','chennai',2000); Insert into d values (102,'kumar',45,'7.20.2002','cardiologist','vellore',68000); Insert into d values (103,'laksmi',40,'9.12.2012','psychiatrist','madurai',70000); Insert into d values (104,'sudha',35,'4.6.2008','psychiatrist','Bangalore',65000); Insert into d values (105,'munna',30,'4.6.2013','null','chennai',1000); Insert into d values (106,'ashok',30,'4.7.2008','cardiologist','Bangalore',65000); Insert into d values (107,'mohan',25,'4.6.2008','psychiatrist','Bangalore',65000); Insert into d values (108,'&bagya',33,'3.7.2013','cardiologist ','chennai',70000); Select * from d; Create table p( P_id int primary key, D_id int foreign key references d(d_id), P_name varchar (20) not null, P_age int not null, P_disease varchar (20) not null, P_Fees int not null); Insert into P Values (1, 102, 'keerthu', 11, 'Fever' , 100), (2, 102, 'arthi', 35, 'Sinus' , 500), (3, 104, 'bala', 69, 'Heart Attack' , 350), (4, 102, 'sameera', 5, 'Cough' , 50), (5, 105, 'vino', 10, 'Cold' , 60), (6, 107, 'Rema', 45, 'Knee pain' , 80), (7, 107, 'pavan', 25, 'Typhoid' , 100), (8, 104, 'yeshwanth', 18, 'Stomach pain' , 70) Select * from d Select avg (d_salary) as Avg_Sal from d; Select D_name, D_salary from D where D_salary<(Select avg (d_salary) from d); Select top 1* from (Select top 2* from d order by d_salary desc)as final order by d_salary Select top 1* from (Select top 7* from d order by d_salary desc)as final order by d_salary Select d_name, len(d_name) as 'length_N' from D Select left (d_name, 3) as '1st 3 letters', d_name from d Select d_name, P_name from d full join p on d.d_id=p.d_id Select d_name as 'DOJ-2013' from d where year(d_doj)=2013; Select D_name as 'Date_Of_Join-Oct' from d where month(d_doj)=10 Select d_name as 'N_DOJ' from d where d_doj='4/07/2008' Select d_name, datediff(year, d_doj, getdate()) as Experience from d Select d_name from d left join p on d.d_id=p.d_id where p_id is null Select top 1 d_name, count(p_id) as 'No.of Patients' from d inner join p on d.d_id=p.d_id Group by d_name Order by count(p_id) desc Select p_name from p where d_id is null
run
|
edit
|
history
|
help
0
DETAILS
2021-03-06_LeetCodeSQL
ms sql where ,like
SQL Server - Multiple Holidays Model
dynamic pivot
SQL Server - UK Holiday Calendar Example
Allocations Check
Solution 3
TestTaskSolutionByTania
test