Instruction
stringlengths
460
3.71k
Output
stringlengths
29
1.3k
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- need details on reimbursements above 1000 raised from '01-Jan-2023' until '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- fetch reimbursements exceeding 1000 for period '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Please retrieve reimbursements more than 1000 between '01-Jan-2023' and '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- List reimbursements greater than 1000 during '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- details reimbursements with amounts higher than 1000 from '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- display reimbursements above 1000 raised between '01-Jan-2023' and '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Please list down reimbursements amount greater than 1000 during '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- reimbursement details where amount exceeds 1000 for '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Fetch reimbursement details for amounts >1000 between '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- I'm looking for reimbursements with amounts over 1000 within '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Retrieve reimbursements are more than 1000 for '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Please show reimbursements with an amount greater than 1000 within '01-Jan-2023' and '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- need reimbursement specifics for amounts exceeding 1000 from '01-Jan-2023' till '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- fetch reimbursements greater than 1000 raised between '01-Jan-2023' and '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- List down reimbursement details with amounts >1000 for '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- details on reimbursements raised between '01-Jan-2023' and '31-Oct-2023' where amount exceeds 1000
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements >1000 between '01-Jan-2023' and '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Amount>1000 for reimbursements '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements >1k in '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Amount>1000 in '01-Jan-2023' - '31-Oct-2023' reimbursements
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements >1000 during '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- 1k+ reimbursements '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements >1000 '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- 1k+ reimbursements in '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Amount>1000 reimbursements '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements>1k '01-Jan-2023' to '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- 1k+ amount '01-Jan-2023' - '31-Oct-2023' reimbursements
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements>1000 '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Amount>1k '01-Jan-2023' - '31-Oct-2023' reimbursements
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements '01-Jan-2023' - '31-Oct-2023' >1000
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Amount>1k in reimbursements '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- '01-Jan-2023' - '31-Oct-2023' reimbursements >1000
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements '01-Jan-2023' - '31-Oct-2023' >1k
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Amount>1000 reimbursements between '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- '01-Jan-2023' - '31-Oct-2023' reimbursements 1k+
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Ex_ReimbursementRequest (R_SysCode INT, RF_ID INT, EmployeeID INT, ReimbursementAmount DECIMAL, Disbursed_Amount DECIMAL, Descriptions NVARCHAR, ActionStatus NVARCHAR, Approval_rejection_Remarks NVARCHAR, Status INT, CreatedById INT, CreatedOn DATETIME, CreatedByMachinIP NVARCHAR, UpdatedById INT, UpdatedOn DATETIME, UpdatedByMachinIP NVARCHAR, UserName NVARCHAR)''CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Reimbursements >1000 '01-Jan-2023' - '31-Oct-2023'
SELECT distinct E.EmpCode, E.Firstname+ ' '+ E.Lastname EmployeeName,isnull(ERR.ReimbursementAmount,0)ReimbursementAmount, isnull(Err.Disbursed_amount,0) as [Disbursed Amount],Descriptions,ActionStatus,Approval_rejection_Remarks FROM Employee AS E INNER JOIN Ex_ReimbursementRequest AS ERR ON E.EmployeeID = ERR.EmployeeID WHERE reimbursementamount>1000 and convert(date,Err.createdon,101) between '01-Jan-2023' and '31-Oct-2023'
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- What's attrition rate in Jan 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition rate for Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- What's attrition percentage in January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- share attrition rate specifically for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- attrition figures for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition rate in first month 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- need attrition rate details for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- What's employee turnover percentage for Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Share attrition rate report for Jan 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- What's attrition ratio for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- attrition percentage in Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition rate for month January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- give attrition rate for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- What's attrition rate in month Jan 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- How many employees left in January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- What's rate attrition in Jan 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Share attrition statistics for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition percentage in first month 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- detail attrition rate for January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- attrition rate in Jan 2023, please
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition rate Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 attrition
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan 2023 attrition
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition rate - Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 - attrition rate
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 staff loss
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition - Jan 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition in Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 turnover
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 attrition data
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition Jan '23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 employee loss
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition - January 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition - Jan 2023
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan 2023 attrition stats
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 employee turnover
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition - January 23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Attrition in January 23
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 staff attrition
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE Employee (EmployeeId INT, UserId INT, ApplicationId INT, RoleId INT, ShiftId INT, UserName NVARCHAR, EmpCode NVARCHAR, FirstName NVARCHAR, LastName NVARCHAR, MiddleName NVARCHAR, FatherName NVARCHAR, ImageFilePath NVARCHAR, Phone NVARCHAR, CellPhone NVARCHAR, IsMobileNumberPublic BIT, OfficePhone NVARCHAR, Extension NVARCHAR, Email NVARCHAR, IsEmailIdPublic BIT, AlternateEmailId NVARCHAR, QuitDate DATETIME, DepartmentId INT, CompanyID INT, BranchID INT, DesignationId INT, ReligionId INT, NationalityId INT, BloodTypeId INT, BloodType NVARCHAR, MaritalStatusId INT, PlaceOfBirth NVARCHAR, BirthDate DATETIME, JoiningDate DATETIME, Gender NVARCHAR, HousePhone NVARCHAR, IsLeavedJob BIT, LeaveJobDate DATETIME, LeaveJobReason NVARCHAR, TaxID NVARCHAR, SocialSecurityNo NVARCHAR, Status INT, ReportingToEmpId INT, CreatedOn DATETIME, UpdatedBy INT, CreatedBy INT, UpdatedOn DATETIME, EmpStatusId INT, ReportingToHrId INT, EmployeeStatus NVARCHAR, title NVARCHAR, PFNo NVARCHAR, ESINo NVARCHAR, SeriesTypeID INT, EmpCodeValue NVARCHAR, IsEmployeeExit BIT, IsfullFinalsettelement BIT, ExitDate DATETIME, RepotingToEMPCode NVARCHAR, CTC DECIMAL, CreatedMachineIP NVARCHAR, UpdatedMachineIP NVARCHAR, IsTDSapplicable BIT, GrossPay DECIMAL, IsExcludePayroll BIT, ReportingToFunctionalManager INT, SubDepartmentId INT, Sub_SubDepartmentId INT, WorkerType INT, EmployeeGrade INT, EmpExitType NVARCHAR, JobLevelId INT, PayTypeId INT, ClientId INT) --Using valid MS SQL Server, answer following questions for tables provided above -- Jan '23 attrition ratio
select cast( '01-Jan-2023' as varchar) StartDate , cast('31-Jan-2023' as varchar) EndDate,*, (totalleft/[Balance Employee Count])*100 AttritionRate from (select cast (sum(totalcount) as real)HeadCount, cast(sum(totalleft) as real) totalleft,sum(Joined) Joined, cast(sum(totalcount-totalleft+Joined) as real) [Balance Employee Count] from ( select count(*) as totalcount ,0 totalleft , 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate< '01-Jan-2023' union all select 0 totalcount, count(*) as totalleft, 0 as Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where LeaveJobDate between '01-Jan-2023' and '31-Jan-2023' union all select 0 as totalcount ,0 totalleft,count(*) Joined FROM [dbo].[Employee] inner join (select EmployeeId from employee where status=1 and companyid=(select distinct e.companyid from employee e )) empIds on [Employee].EmployeeId=empIds.EmployeeId where JoiningDate between '01-Jan-2023' and '31-Jan-2023') as aa) as ComplexQuery
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- details short leaves taken in current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- I'm interested in obtaining detailed information about short leaves taken year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- furnish with comprehensive report on short leaves taken in current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- give breakdown short leaves specifically for current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- I'd like to see report highlighting short leaves in current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Please with information on short leaves taken, focusing on current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Retrieve data on short leaves, specifically for ongoing year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Show details short leaves taken in current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- List down short leaves, emphasizing current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- I'm looking for report detailing short leaves, with focus on year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- generate report on short leaves, specifically for current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- need breakdown my short leaves, highlighting current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- with report on short leaves for current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Show information on short leaves, with focus on year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Retrieve details on short leaves, particularly for current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- I'm interested in data related to short leaves in current year in Noida branch assist
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- generate report on short leaves, specifically for ongoing year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Please furnish with information on short leaves in current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- show breakdown short leaves in current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- short leaves year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Short leaves, current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Short leaves, year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Short leave details, current year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')
CREATE TABLE employeedetails (EmployeeId numeric,UserId int,UserName varchar,EmpCode varchar,title varchar,FirstName nvarchar,MiddleName nvarchar,FatherName varchar,Phone nvarchar,CellPhone nvarchar,IsMobileNumberPublic bit,OfficePhone nvarchar,Extension varchar,Email nvarchar,IsEmailIdPublic bit,AlternateEmailId varchar,QuitDate datetime,DeptName varchar,DesignationName varchar,Religion varchar,Nationality varchar,PlaceOfBirth nvarchar,BirthDate datetime,JoiningDate datetime,Gender varchar,HousePhone nvarchar,MaritalStatusName varchar,BranchName varchar,ReportingManagerName nvarchar,EmployeeGrade int,IsEmployeeExit bit,ExitDate datetime,ReasonToLeave nvarchar,IsLeavedJob bit,SocialSecurityNo nvarchar,LeaveJobDate datetime,Status int,CreatedOn datetime,UpdatedOn datetime,PFNo nvarchar,ESINo nvarchar,CTC decimal,CreatedMachineIP varchar,UpdatedMachineIP varchar,IsTDSapplicable bit,GrossPay decimal,WorkerType int,EmpExitType nvarchar,JobLevelName varchar,companyid int,branchid int)'' CREATE TABLE Employee (EmployeeId numeric, UserId int, ApplicationId int, RoleId int, ShiftId int, UserName varchar, EmpCode varchar, FirstName nvarchar, LastName nvarchar, MiddleName nvarchar, FatherName nvarchar, ImageFilePath nvarchar, Phone nvarchar, CellPhone nvarchar, IsMobileNumberPublic bit, OfficePhone nvarchar, Extension nvarchar, Email nvarchar, IsEmailIdPublic bit, AlternateEmailId nvarchar, QuitDate datetime, DepartmentId int, CompanyID int, BranchID int, DesignationId int, ReligionId int, NationalityId int, BloodTypeId int, BloodType nvarchar, MaritalStatusId int, PlaceOfBirth nvarchar, BirthDate datetime, JoiningDate datetime, Gender varchar, HousePhone nvarchar, IsLeavedJob bit, LeaveJobDate datetime, LeaveJobReason nvarchar, TaxID int, SocialSecurityNo int, Status nvarchar, ReportingToEmpId int, CreatedOn datetime, UpdatedBy int, CreatedBy int, UpdatedOn datetime, EmpStatusId int, ReportingToHrId int, EmployeeStatus varchar, title nvarchar, PFNo int, ESINo varchar, SeriesTypeID bit, EmpCodeValue decimal, IsEmployeeExit bit, IsfullFinalsettelement bit, ExitDate datetime, RepotingToEMPCode int, CTC int, CreatedMachineIP nvarchar, UpdatedMachineIP nvarchar, IsTDSapplicable bit, GrossPay decimal, IsExcludePayroll bit, ReportingToFunctionalManager bit, SubDepartmentId int, Sub_SubDepartmentId int, WorkerType int, EmployeeGrade int, EmpExitType int, JobLevelId int, PayTypeId int, ClientId int)'' CREATE TABLE tblShortLeaves(ShortLeaveId int,EmployeeId int,DateOfShortLeave date,DateOfApplication date,LeaveStatus nvarchar,LeaveType nvarchar,Reason nvarchar,IsActive bit,HalfDayType nvarchar,ApprovedById nvarchar,DeclineById nvarchar,CreatedOn date,CreatedBy int,CreatedMachineIp nvarchar,UpdatedOn date,UpdatedBy int,UpdatedMachineIp nvarchar) --Using valid MS SQL Server, answer following questions for tables provided above -- Short leaves report, year in Noida branch
SELECT e.EmpCode, e.FirstName + ' ' + ISNULL(e.MiddleName,'') AS EmployeeName, e1.EmpCode AS ApprovedByCode, e1.FirstName + ' ' + ISNULL(e1.MiddleName,'') AS ApprovedBy, CAST(CONVERT(DATE, [DateOfShortLeave], 101) AS VARCHAR) AS [DateOfShortLeave], CAST(CONVERT(DATE, [DateOfApplication], 101) AS VARCHAR) AS [DateOfApplication], [LeaveStatus], [LeaveType], [Reason], CASE WHEN [HalfDayType] = 'FH' THEN 'FirstHalf' WHEN [HalfDayType] = 'SH' THEN 'SecondHalf' ELSE [HalfDayType] END AS [HalfDayType] FROM [dbo].[tblShortLeave] C INNER JOIN employee e ON c.employeeid = e.employeeid LEFT JOIN employee e1 ON c.[ApprovedById] = e1.employeeid WHERE YEAR([DateOfShortLeave]) = YEAR(GETDATE()) AND EXISTS (SELECT 1 FROM employeedetails empd WHERE empd.employeeid = e.employeeid AND empd.BranchName = 'Noida')