Hi all, I need help in forming SQL Query ..
My Master Tables-
1. Employees
ID
EmployeeName
ManagerName
EmailID
Dept
Flag
1
Girish.Shah
Ashish.Chakraborty
[email protected]
A
2
Grishma.Sharma
B
3
Sanjay.Dutta
C
4
Arpita.Sinha
Jignasa.Ved
5
Alok.Kadu
6
7
Amrita.Verma
Pooja.Kapil
8
9
Sumit.Sharma
10
Column-“EmployeeName” – List of all employess. (Even Managers are employess).
Column – ID and EmployeeName – are unique.
2. TrainingType
Training Type
Technical
Non - Technical
3. Training Level
TrainingLevel
Beginner
Intermediate
Professional
4. Training Name
TrainingLevelID
TrainingTypeID
TrainingName
Oracle 12c
Email writing skills
Presentation Skills
Adobe
TrainingLEvelID – ForeignKEy of ID column of TrainingLevel table.
TrainingTypeID – ForeignKey of ID Column of TrainingType table.
5. Other subject
Other TrainingName
LINQ
Business meetings
Managing Top performers
Video Streaming
Logic-
If the user does not find appropriate training name in the dropdownlist in front-end, he will select a subject from “Other Subject” in other dropdownlist from front-end.
TRANSACTION TABLE –
ManagerID
EmployeeID
TrainingID
OtherSubjectID
TimeLine
Remarks
0
Q1
Abcm
Q2
Dsf
Q3
Sdf
Q4
T
S
D
df
ManagerID – ID in EmployeeTable – 3,6,8 are managers.
Logic – “select count(*) from Employees where managerName = @ManagerName (parameter from front-end).
If count(*) > 0; select employeesname from Employees where managername = @ManagerName.
EmployeeID – it can be anyID (Every Manager is employee and each each employee has a manager).
TrainingTypeID – Foreign Key of TrainingType table.
If user selects training name from 1st dropdownlist, then that ID will be inserted to TrainingID and OtherSubjectID will be 0.
If user select “Other Subject”, then TrainingTypeID will be 0.
I need the queries for following output -
1.
Subject Name
Other Subject
Total Reports
Level
NULL
1 (Only 1 employee was send to oracle training)
Beginner - 1
2 (Only 2 person went for adobe training)
Beginner-1
Intermediate -1
How do I get this query ?
One Columns – List of Subjects
Second Column – List of other subject
Total Report – Count (*) of how many employee attended that training
Level Wise division – How many for beginner, how many for intermediate, how many for expert
2. The “Total Reports” column will be a hyperlink – When the user will click on “1” or “2”, he must get the following –
Subject
Oterh Subject
Employee
Manager
LevelOfTraining
Quarter
Percentage
50% ( 2 persons report to Ashish.Chakraborty, he sent only 1 person to oracle 12c Training)
75% ( 4 persons report to Sanjay.Dutta , he sent only 3 persons to adobe training ).
And likewise – the entire list…
Please guide..