Creating X amount of rows in an append

Smtgr14

New member
Local time
Today, 11:34
Joined
Jan 15, 2015
Messages
7
I am trying to build an incentive calculator for my company.
I need a query that will take, for each employee,
Append rows as follows:
Emp1 | Attendance |
Emp1 | CSAT Score |
Emp1 | Quality Score |
Emp2 | Attendance |
Emp2 | CSAT Score |
Emp2 | Quality Score |
...etc...

The Attendance, CSAT Score, Quality Score are from a table named PARAMETERS where each department will have them listed as
Dept1 | Attendance | >90% |$10
Dept1 | CSAT Score | >8.0 |$10
Dept1 | Quality Score | >3.5 |$20
Dept2 | Attendance | >95% |$15
...etc...

I can do the lookups needed to find out which department an employee belongs to, but I have no idea how to get the Employee to be listed in multiple rows like this. Does anyone have any ideas?
 
If you have a table with employees and another with your options (the 3 you've listed), a query that includes both tables without a join will produce your result (a Cartesian product).
 
So just include the tables, and the fields in the query.

SELECT Inventory.employeeID, Inventory.Name, Inventory.Department Parameters.ParamName
FROM Inventory, Parameters

But what if I need only certain rows from the Parameters to be included depending on what the department is?
My parameters table looks like:
[Param Name]|[Department]|...
Attendance |Dept1 |...
CSAT |Dept1 |...
Attendance |Dept2 |...
Attendance |Dept3 |...
CSAT |Dept3 |...
 
I've worked it out.

I added the following clause:
WHERE Parameters.Department = Inventory.Department
This gives me the output I need.
 
Sorry, lost track of the thread. Glad you got it sorted, and thanks for following up with the answer.
 

Users who are viewing this thread

Back
Top Bottom