I am again stuck up in making SQL Query. I am sharing the data and system flow.
Above are the 2 tables and the Report format that I am not able to make.
Hello Team,
I have two tables -
1. tbl_EquipmentMaster
2. tbl_EquipmentCertification
1. tbl_EquipmentMaster
ID - Primary Key
EmpCode - EmployeeCode
EquipName - Equipment Name
Brand - Brand of Equipment
SerialNumber - SerialNumber of Equipments
Status - Assigned - that equipment is assigned to that employee
Active - 1- Active ; 0 - InActive
2. tbl_EquipmentCertification
ID - Primary Key
EmpCode - EmployeeCode
EquipName - Equipment Name
SerialNumber - SerialNumber of Equipments
Status - Assigned - that equipment is assigned to that employee
CertifyStatus - 1 - Employee Owns the equipment ; 0 - Employee DO NOT Own the equipment; 2- Newly Added
CertifiedBy - Same as EmpCode
CertifiedOn - Date
Active - 1- Active ; 0 - InActive
EquipmentMasterID - ForeignKey of ID Column of table tbl_EquipmentMaster
Flow -
When emp-A1 logs in, he gets a list of assets assigned to him from "tbl_EquipmentMaster" table in a gridview.
It's a check-box gridview, as A1 can select any number of records from the gridview.
There are 3 buttons on the page - "I OWN", "I DO NOT OWN" , "ADD NEW EQUIPMENT"
WHen A1 selects 3 records (with SerialNumber S1,S2.S3) and clicks on "I OWN" button, the records are inserted in table - "tbl_EquipmentCertification".
For these records, CertifyStatus = "1" -> measn that these equipments are with employee-A1.
WHen A1 selects 3 records (with SerialNumber S4,S5) and clicks on "I DO NOT OWN" button, the records are inserted in table - "tbl_EquipmentCertification".
For these records, CertifyStatus = "0" -> measn that these equipments ARE NOT with employee-A1.
WHen A1 clicks on "ADD NEW EQUIPMENT" button, records are inserted in
table - "tbl_EquipmentCertification", where CertifyStatus = "2" -> measn that these equipments newly added by employee-A1.
Report -
1. PendingAssets - total count from table "tbl_EquipmentMaster"
2. Total Certified Assets - total count from table "tbl_EquipmentCertification" where certifystatus = 1
3. Total Do Not Own Devices - total count from table "tbl_EquipmentCertification" where certifystatus = 0
4. Total Added New Assets - total count from table "tbl_EquipmentCertification" where certifystatus = 2
5. Total Assets - > Certified Assets Count + Newly Added Assets Count