Hello, i have a table called tblschedule that has field for resourceID, employeeID, and scheduleDate. And also i have another table called tblResource that has resourceID and ResourceName. The third table called tblEmployee has employeeID, employeeFirstName and employeeLastname. I want to get a report for each resourceName (not ResourceID) that per employee schedule (COUNT). I need the report has ResourceName field, employeeName field and count. How can i write a store procedure as it need join three table to get the count. Thank you very much!Hello, i have a table called tblschedule that has field for resourceID, employeeID, and scheduleDate. And also i have another table called tblResource that has resourceID and ResourceName. The third table called tblEmployee has employeeID, employeeFirstName and employeeLastname. I want to get a report for each resourceName (not ResourceID) that per employee schedule (COUNT). I need the report has ResourceName field, employeeName field and count. How can i write a store procedure as it need join three table to get the count. Thank you very much!
assuming the tables are as follows,
tblEmployee
(
EmployeeID Int
EmployeeFirstName Varchar(50)
EmployeeLastName Varchar(50)
tblResource
(
ResourceID Int ,
ResourceName Varchar(50)
)
tblSchedule
(
ResourceID Int ,
EmployeeID Int ,
ScheduleDate DateTime
)
Try this and let me know if u have much refined version of this...
Select tE.EmployeeFirstName, tE.EmployeeLastName,tR.ResourceName,EmpCount.Sched ule
From tblEmployee tE
Inner Join tblSchedule tSE
On tE.EmployeeID = tSE.EmployeeID
Inner join tblResource tR
On tR.ResourceID = tSE.ResourceID
Inner Join (Select EmployeeID,Count(EmployeeID) As Schedule From tblSchedule Group By EmployeeID) EmpCount
On tE.EmployeeId = EmpCount.EmployeeID|||Thank you very much! But i have one more question, i would like to group the resourceID too. The result like:
Laptop John 12
Laptop smith 2
projector Rick 2
Cellphone Kim 2
Is it possible? Many thanks.
Showing posts with label resourceid. Show all posts
Showing posts with label resourceid. Show all posts
Thursday, March 8, 2012
aggregate in multiple table.
Labels:
aggregate,
database,
employeeid,
field,
microsoft,
multiple,
mysql,
oracle,
resourceid,
scheduledate,
server,
sql,
table,
tblschedule
Tuesday, March 6, 2012
aggregate function
I have three tables, tblschedule, tblresource and tblemployeename.
in tblschedule table there are scheduleID, resourceID and employeeID. In tblResource there are ResourceID and ResourceName. In tblemployeename there are EmployeeID, EmployeeFName and EmployeeLame. I want to have a report that show how many times the resource has been reserved by employee. i would like to have a report. Look like the following:
ResourceName EmployeeFName EmployeeLName (Or use EmployeeName) Number of record.
How to write a query? I use asp.net as front end.
Thank for your help.The aggregate function you are looking for is Count().
in tblschedule table there are scheduleID, resourceID and employeeID. In tblResource there are ResourceID and ResourceName. In tblemployeename there are EmployeeID, EmployeeFName and EmployeeLame. I want to have a report that show how many times the resource has been reserved by employee. i would like to have a report. Look like the following:
ResourceName EmployeeFName EmployeeLName (Or use EmployeeName) Number of record.
How to write a query? I use asp.net as front end.
Thank for your help.The aggregate function you are looking for is Count().
Labels:
aggregate,
database,
employeeid,
function,
microsoft,
mysql,
oracle,
resourceid,
scheduleid,
server,
sql,
table,
tables,
tblemployeename,
tblresource,
tblschedule
Subscribe to:
Posts (Atom)