Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
(
departmentId int PRIMARY KEY Identity(1,1),
departmentName varchar(255),
isActive bit,
createdUser int,
createdDate DateTime
)
INSERT INTO Department(departmentName,isActive,createdUser,createdDate)
VALUES('HR',1,2,'01-22-2020'),
('Marketing',0,3,'01-22-2020'),
('Sales',1,4,'01-22-2020')
INSERT INTO Department(departmentName,isActive,createdUser,createdDate)
VALUES('Finance',1,2,GETDATE())
SELECT * FROM Department
---------------------------------------------------------------------------------------------------------------------------------------------------
CREATE TABLE Employee
(
employeeId int PRIMARY KEY Identity(1,1),
firstName varchar(255),
lastName varchar(255),
DOJ DateTime,
departmentId int ,
[address] nvarchar(255),
city varchar(100),
createdUser int,
createdDate DateTime
)
INSERT INTO Employee(firstName,lastName,DOJ,departmentId,[address],city,createdUser,createdDate)
VALUES('Milin','Khalas',GETDATE(),3,'78 Chaya Bunglow,Ahmedabad','Surat',1,GETDATE()),
('Abhisek','Ippkayal',GETDATE(),4,'76 Chaya Bunglow,Ahmedabad','Chennai',1,GETDATE()),
('Hitesh','Chaudhary',GETDATE(),5,'77 Chaya Bunglow,Ahmedabad','Ahmedabad',1,GETDATE())
SELECT * FROM Employee
CREATE VIEW [vw_employee]
as
select firstName+' '+lastName as FullName,DOJ,departmentId,[address],city,createdUser,createdDate from Employee
select * from [vw_employee]
24-1-20
CREATE TABLE Login(
loginId int PRIMARY KEY IDENTITY(1,1),
employeeId int FOREIGN KEY REFERENCES Employee(employeeId),
userName varchar(255),
[password] nvarchar(255),
createdUser int,
createdDate DateTime);
INSERT INTO Login(employeeId,userName,[password],createdUser,createdDate)
VALUES(1,'Bhavesh Koshti','QmhhdmVzaCQxMg==',1,GETDATE()),
(1,'Hitesh Rajput','SGl0ZXNoJjIx',2,GETDATE());
ALTER TABLE Employee ADD Email nvarchar(255);
ALTER TABLE Employee ADD UNIQUE(Email)
ALTER TABLE Employee
ADD CONSTRAINT df_email
DEFAULT '[email protected]' FOR Email;
ALTER TABLE Persons
ALTER City SET DEFAULT 'Sandnes';
ALTER TABLE Persons
ADD CONSTRAINT df_City
DEFAULT 'Sandnes' FOR City;
1) select * from Login where employeeId in (select employeeId from Employee where departmentId=(select departmentId from Department where departmentName='HR'))
2) delete from Login where employeeId in (select employeeId from Employee where departmentId=(select departmentId from Department where departmentName='HR'))
3) delete from Employee where departmentId=(select departmentId from Department where departmentName='HR')
ALTER TABLE Department
ADD CONSTRAINT df_isactive
DEFAULT 1 FOR isActive;
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DAY 3
CREATE TABLE EmployeeSalary
(
Id int PRIMARY KEY Identity(1,1),
employeeId int REFERENCES Employee(employeeId),
CTC numeric(18,2),
createdUser int,
createdDate DateTime
)
select d.departmentName,count(employeeId) as Numberofemployees from Employee e
join Department d on e.departmentId=d.departmentId
GROUP BY d.departmentName
10500,15000,22700,26500,22700,55000,41000,65000,88000,150000,98000
select d.departmentId,departmentName ,sum(CTC) as TotalSalary
from Department d
left join Employee e
on e.departmentId= d.departmentId
inner join EmployeeSalary s
on e.employeeId= s.employeeId
group by d.departmentName, d.departmentId
select firstName, CTC from Employee e
inner join EmployeeSalary s
on s.employeeId = e.employeeId
where s.CTC=(select max(CTC)AS ctc from EmployeeSalary)
select firstName, CTC from Employee e
inner join EmployeeSalary s
on s.employeeId = e.employeeId
where s.CTC=(select min(CTC)AS ctc from EmployeeSalary)
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team