Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
it
create table travel ( eid int primary key, ph_no int, address varchar(20) ) create table travelers ( eno int primary key, gender varchar(2), age int ) create table manages ( eid int foreign key references travel(eid) on delete cascade on update cascade, eno int foreign key references travelers(eno) on delete cascade on update cascade ) create table Nepalese_community ( nid int primary key, location varchar (30) ) create table visiting ( eno int foreign key references travelers(eno) on delete cascade on update cascade, nid int foreign key references nepalese_community(nid) on delete cascade on update cascade ) create table agencies ( aid int primary key, contact_no int ) create table contacts_to ( aid int foreign key references agencies(aid) on delete cascade on update cascade, nid int foreign key references Nepalese_community(nid) on delete cascade on update cascade ) insert into travel (eid, ph_no, address) values(1, 555555,'kalanki'); insert into travel (eid, ph_no, address) values(2, 566665,'kalimti'); insert into travel (eid, ph_no, address) values(3, 777775,'teku'); insert into travel (eid, ph_no, address) values(4, 888885,'pokhara'); insert into travel (eid, ph_no, address) values(6, 999995,'koteshwor'); insert into travel (eid, ph_no, address) values(7, 533335,'nakhu'); insert into travel (eid, ph_no, address) values(8, 444455,'bhanimandal'); insert into travel (eid, ph_no, address) values(9, 511211,'satungal'); insert into travel (eid, ph_no, address) values(10, 550005,'thankot'); insert into travel (eid, ph_no, address) values(11, 533355,'sanepa'); insert into travel (eid, ph_no, address) values(12, 555855,'sinamngal'); insert into travel (eid, ph_no, address) values(13, 515555,'baneshwor'); insert into travel (eid, ph_no, address) values(14, 523555,'tripureshwor'); insert into travel (eid, ph_no, address) values(15, 895555,'balkhu'); insert into travel (eid, ph_no, address) values(16, 555555,'ekantakuna'); insert into travel (eid, ph_no, address) values(17, 355555,'patan'); insert into travel (eid, ph_no, address) values(18, 855555,'tinkuney'); insert into travel (eid, ph_no, address) values(19, 455555,'tokha'); insert into travel (eid, ph_no, address) values(20, 558955,'jhor'); insert into travelers(eno, gender, age) values(21, 'M',13) insert into travelers(eno, gender, age) values(22, 'F',12) insert into travelers(eno, gender, age) values(23, 'M',14) insert into travelers(eno, gender, age) values(24, 'M',19) insert into travelers(eno, gender, age) values(25, 'F',10) insert into travelers(eno, gender, age) values(26, 'F',15) insert into travelers(eno, gender, age) values(27, 'M',13) insert into travelers(eno, gender, age) values(28, 'M',19) insert into travelers(eno, gender, age) values(29, 'F',14) insert into travelers(eno, gender, age) values(30, 'M',11) insert into travelers(eno, gender, age) values(31, 'M',13) insert into travelers(eno, gender, age) values(32, 'F',15) insert into travelers(eno, gender, age) values(33, 'M',23) insert into travelers(eno, gender, age) values(34, 'M',20) insert into travelers(eno, gender, age) values(35, 'M',30) insert into travelers(eno, gender, age) values(36, 'F',31) insert into travelers(eno, gender, age) values(37, 'M',43) insert into travelers(eno, gender, age) values(38, 'F',23) insert into travelers(eno, gender, age) values(39, 'F',33) insert into travelers(eno, gender, age) values(40, 'M',22) insert into manages(eid, eno) values(1,21); insert into manages(eid, eno) values(2,22); insert into manages(eid, eno) values(3,23); insert into manages(eid, eno) values(4,24); insert into manages(eid, eno) values(6,25); insert into manages(eid, eno) values(7,26); insert into manages(eid, eno) values(8,27); insert into manages(eid, eno) values(9,28); insert into manages(eid, eno) values(10,29); insert into manages(eid, eno) values(12,30); insert into manages(eid, eno) values(12,31); insert into manages(eid, eno) values(13,32); insert into manages(eid, eno) values(14,33); insert into manages(eid, eno) values(15,34); insert into manages(eid, eno) values(16,35); insert into manages(eid, eno) values(17,36); insert into manages(eid, eno) values(18,37); insert into manages(eid, eno) values(19,38); insert into manages(eid, eno) values(20,39); insert into manages(eid, eno) values(20,40); insert into Nepalese_community(nid,location)values(50,'kathmandu') insert into Nepalese_community(nid,location)values(51,'Pokhara') insert into Nepalese_community(nid,location)values(52,'Chitwan') insert into Nepalese_community(nid,location)values(53,'Pharping') insert into Nepalese_community(nid,location)values(54,'Nagarkot') insert into Nepalese_community(nid,location)values(55,'kulekhani') insert into Nepalese_community(nid,location)values(56,'Butwal') insert into Nepalese_community(nid,location)values(57,'lumbini') insert into Nepalese_community(nid,location)values(58,'bhairawa') insert into Nepalese_community(nid,location)values(59,'kanchanpur') insert into Nepalese_community(nid,location)values(60,'khotang') insert into Nepalese_community(nid,location)values(61,'dang') insert into Nepalese_community(nid,location)values(62,'kashi') insert into Nepalese_community(nid,location)values(63,'kailali') insert into Nepalese_community(nid,location)values(64,'mustang') insert into Nepalese_community(nid,location)values(65,'manag') insert into Nepalese_community(nid,location)values(66,'jhor') insert into Nepalese_community(nid,location)values(67,'bhaktapur') insert into Nepalese_community(nid,location)values(68,'patan') insert into Nepalese_community(nid,location)values(69,'changunarayan') insert into Nepalese_community(nid,location)values(70,'kalanki') insert into visiting(eno,nid)values(21,50); insert into visiting(eno,nid)values(22,51); insert into visiting(eno,nid)values(23,52); insert into visiting(eno,nid)values(24,53); insert into visiting(eno,nid)values(25,54); insert into visiting(eno,nid)values(26,55); insert into visiting(eno,nid)values(27,56); insert into visiting(eno,nid)values(28,57); insert into visiting(eno,nid)values(29,58); insert into visiting(eno,nid)values(30,59); insert into visiting(eno,nid)values(31,60); insert into visiting(eno,nid)values(32,61); insert into visiting(eno,nid)values(33,62); insert into visiting(eno,nid)values(34,63); insert into visiting(eno,nid)values(35,64); insert into visiting(eno,nid)values(36,65); insert into visiting(eno,nid)values(37,66); insert into visiting(eno,nid)values(38,67); insert into visiting(eno,nid)values(39,68); insert into visiting(eno,nid)values(40,69); insert into agencies(aid, contact_no)values(80,12111); insert into agencies(aid, contact_no)values(81,11311); insert into agencies(aid, contact_no)values(82,14111); insert into agencies(aid, contact_no)values(83,11511); insert into agencies(aid, contact_no)values(84,16111); insert into agencies(aid, contact_no)values(85,17111); insert into agencies(aid, contact_no)values(86,11811); insert into agencies(aid, contact_no)values(87,19111); insert into agencies(aid, contact_no)values(88,10111); insert into agencies(aid, contact_no)values(89,21111); insert into agencies(aid, contact_no)values(90,31111); insert into agencies(aid, contact_no)values(91,43111); insert into agencies(aid, contact_no)values(92,51111); insert into agencies(aid, contact_no)values(93,61111); insert into agencies(aid, contact_no)values(94,71111); insert into agencies(aid, contact_no)values(95,81111); insert into agencies(aid, contact_no)values(96,91111); insert into agencies(aid, contact_no)values(98,10111); insert into agencies(aid, contact_no)values(99,12111); insert into agencies(aid, contact_no)values(100,13111); insert into contacts_to(aid, nid)values( 80,50); insert into contacts_to(aid, nid)values( 81, 51); insert into contacts_to(aid, nid)values( 82,52); insert into contacts_to(aid, nid)values( 83,53); insert into contacts_to(aid, nid)values( 84,54); insert into contacts_to(aid, nid)values( 85,55); insert into contacts_to(aid, nid)values( 86,56); insert into contacts_to(aid, nid)values( 87,57); insert into contacts_to(aid, nid)values( 88,58); insert into contacts_to(aid, nid)values( 89,59); insert into contacts_to(aid, nid)values( 90,60); insert into contacts_to(aid, nid)values( 91,61); insert into contacts_to(aid, nid)values( 92,50); insert into contacts_to(aid, nid)values( 93,50); insert into contacts_to(aid, nid)values( 94,50); insert into contacts_to(aid, nid)values( 80,50); insert into contacts_to(aid, nid)values( 80,50); create table informs ( aid int foreign key references agencies(aid) on delete cascade on update cascade, eid int foreign key references travel(eid) on delete cascade on update cascade ) create table Money ( mid int primary key, quantity int ) create table pays ( mid int foreign key references money(mid) on delete cascade on update cascade, eno int foreign key references travelers(eno) on delete cascade on update cascade ) insert into informs(aid,eid) values(80,1); insert into informs(aid,eid) values(81,2); insert into informs(aid,eid) values(82,3); insert into informs(aid,eid) values(83,4); insert into informs(aid,eid) values(84,6); insert into informs(aid,eid) values(85,7); insert into informs(aid,eid) values(86,8); insert into informs(aid,eid) values(88,9); insert into informs(aid,eid) values(89,10); insert into informs(aid,eid) values(90,11); insert into informs(aid,eid) values(91,12); insert into informs(aid,eid) values(92,13); insert into informs(aid,eid) values(93,14); insert into informs(aid,eid) values(94,15); insert into informs(aid,eid) values(80,16); insert into informs(aid,eid) values(80,17); insert into informs(aid,eid) values(80,18); insert into informs(aid,eid) values(80,20); insert into money(mid, quantity)values(100, 40); insert into money(mid, quantity)values(101, 41); insert into money(mid, quantity)values(102, 42); insert into money(mid, quantity)values(103, 43); insert into money(mid, quantity)values(104, 44); insert into money(mid, quantity)values(105, 45); insert into money(mid, quantity)values(106, 45); insert into money(mid, quantity)values(108, 46); insert into money(mid, quantity)values(109, 48); insert into money(mid, quantity)values(110, 49); insert into money(mid, quantity)values(112, 50); insert into money(mid, quantity)values(113, 51); insert into money(mid, quantity)values(114, 52); insert into money(mid, quantity)values(115, 53); insert into money(mid, quantity)values(116, 54); insert into money(mid, quantity)values(117, 55); insert into money(mid, quantity)values(118, 40); insert into money(mid, quantity)values(119, 40); insert into pays(mid,eno)values(100,21); insert into pays(mid,eno)values(101,22); insert into pays(mid,eno)values(102,23); insert into pays(mid,eno)values(103,24); insert into pays(mid,eno)values(104,25); insert into pays(mid,eno)values(105,26); insert into pays(mid,eno)values(106,28); insert into pays(mid,eno)values(108,29); insert into pays(mid,eno)values(109,31); insert into pays(mid,eno)values(110,32); insert into pays(mid,eno)values(113,33); insert into pays(mid,eno)values(112,34); insert into pays(mid,eno)values(114,25); insert into pays(mid,eno)values(115,24); insert into pays(mid,eno)values(116,23); insert into pays(mid,eno)values(118,22); insert into pays(mid,eno)values(119,21); select * from travel
run
|
edit
|
history
|
help
0
Preppin Data Challenge - Week 8
Second Query
Output
QLDT_TUAN 7
Stuff code in sql
Greatest_N_Per_Group
SQL5
Task_6_Final
SQL Server - NULL values with IN and NOT IN (Solution)
MS SQL Joins