Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Get duplicate row occurance of different date

$
0
0

Hello,

I want to retrieve staff who attend less than 80% for a meeting type assuming we have 10 meetings per list.

- The column for Meeting table "Date" means the date that the staff miss the meeting

- There are 2 type of meetings: Team Meeting, Board Meeting

- Each type of Meeting has 10 sessions each so Team Meeting has 10 & Board Meeting has 10.

If a staff miss the same meeting on 3 different dates (less than 80% for a meeting type),
the output will give the meeting that this staff has missed.

(e.g.)
From the Meeting table, staffID 1 (Dan) did not attend the Team Meeting held on dates 2013-01-15,2013-01-18,2013-01-20

3/10 * 100% = 30%
100 - 30% = 70% [output this staff as has less than 80% of overall attendance]

My query correct dont look correct if a staff have more than 2 records on same day, how do i get the output?

SELECT a.staffName, b.Name, 
(100 - ((COUNT(c.staffID) * 100) / 10)) AS 'Participation%' 
from Staff AS a, listType AS b, Meeting AS c
where a.staffID = c.staffID AND 
b.list = c.list 
GROUP BY a.staffName, b.list
HAVING COUNT(c.staffID) > 2

Meeting Table:

staffID list date
------------------------
1 A 2013-01-15
2 B 2013-01-17
1 B 2013-01-17
1 A 2013-01-18
2 B 2013-01-19
1 A 2013-01-20
2 C 2013-01-21

listType Table:
list Name
---------------------
A Team Meeting
B Board Meeting

Staff Table:
staffID staffName
---------------------
1 Dan
2 Jane

OUTPUT:

staffName Name Participation%
------------------------
Dan 
Team Meeting70

Thanks for any help,

yummymelon


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>