Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Doc
Create table Doctors( 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 Doctors Values (101, 'abi', 30, '10/12/2018', 'cardiologist, 'Chennai', 5), (102, 'sam', 30, '10/9/2014', 'Dermatologist', 'Chennai', 4), (103, 'sandy', 23, '05/31/2012', 'Cardiologist', 'Madurai', 4.5), (104, 'magi', 30, '03/25/2008', 'psychiatrist, 'Coimbatore', 5), (105, ‘@#*333’, 39, ‘07/18/2020’, ‘Orthopaedist’, ‘Vellore’, 6) Insert into Doctors(d_id, d_name, d_age, d_doj, d_city, d_salary) values (01, 'tamizhl', 30, '11/20/2015', 'Vellore', 3), (02, 'ranjitha', 28, '06/22/2020', 'chennai', 3.5) Select * from doctors; Create table patients( P_id int primary key, D_id int foreign key references doctors(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 Patients Values (1101, 12, 'Geetha', 11, 'Fever' , 100), (1102, 11, 'Mani', 35, 'Sinus' , 500), (1103, 14, 'Siva', 69, 'Heart Attack' , 350), (1104, 12, 'Gimma', 5, 'Cough' , 50), (1105, 15, 'Grija', 10, 'Cold' , 60), (1106, 16, 'Reetha', 45, 'Knee pain' , 80), (1107, 15, 'Sita', 25, 'Typhoid' , 100), (1108, 12, 'Gowry', 18, 'Stomach pain' , 70) Select * from Patients; Select D_name, d_age+5 as 'Age After 5 Yrs', d_salary*12 as 'Annual Income' From Doctors; Select D_city from doctors group by d_city Select D_name, D_city from Doctors where D_city not in ('chennai', 'Vellore'); Select D_name, D_salary from Doctors where D_salary not between 3 and 4; Select D_name, D_specialist from Doctors where d_specialist is null; Select top 3 d_name, d_salary from doctors Order by d_salary desc; Select d_name from doctors where d_name like '[a/e/i/o/u]%'; Select d_name from doctors where d_name like '[m/r]%'; Select d_name from doctors where d_name not like ‘[a-z]%’; Select count(d_id) as 'No.of Doctors' from Doctors; Select count(d_id) as 'No.of Doctors from chennai' from doctors where d_city='chennai'; Select d_city, count(d_id) as 'No.of Doctors' from Doctors group by d_city; Select d_city, count(d_id) as 'No.of Doctors' from Doctors where count(d_id)>1 group by d_city;
run
|
edit
|
history
|
help
0
a
transaction in sql server
Demo
hi
test
Recursos_Humanos
Employee
persons
Mc170404738
Adding, subtracting, rounding and calculating differences