Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
davidsong
Starting Member
6 Posts |
Posted - 2007-04-12 : 02:03:39
|
| Hi all,I have two tables, EMPLOYEE_TBL and EMPLOYEESTAR_TBL, the first table stores all the employees infomation and the other table stores the poll items for every employee.Now I want to query all the employees and the avg poll qualtity into one view. That is I want output the data just like:employeeName, employeeEmail, employeeStarsNumberAVGValue ...How to do it? Thanks you very much.David |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-12 : 02:07:31
|
[code]select e.employeeName, e.employeeEmail, employeeStarsNumberAVGValue = avg(somecol)from EMPLOYEE_TBL e inner join EMPLOYEESTAR_TBL sgroup by e.employeeName, e.employeeEmail[/code] KH |
 |
|
|
davidsong
Starting Member
6 Posts |
Posted - 2007-04-12 : 02:20:26
|
| Thanks a lot to khtanI wrote the query like above you wrote, select e.empname, e.empemail,stars = avg(s.startnum)from EMPLOYEE_TBL e inner join EMPSTARS_TBL sgroup by e.empname, e.empemailerror occored: Error Executing Database Query. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-12 : 02:21:52
|
where & how do you execute the query ? in SQL Server Management Studio ? KH |
 |
|
|
davidsong
Starting Member
6 Posts |
Posted - 2007-04-12 : 02:24:28
|
| I execute the it in Access 2007 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-12 : 02:26:46
|
try thisselect e.employeeName, e.employeeEmail, avg(somecol) as employeeStarsNumberAVGValuefrom EMPLOYEE_TBL e inner join EMPLOYEESTAR_TBL sgroup by e.employeeName, e.employeeEmail BTW, this is a SQL Server 2005 forum. For Ms Access, please post at http://www.sqlteam.com/forums/forum.asp?FORUM_ID=3 KH |
 |
|
|
davidsong
Starting Member
6 Posts |
Posted - 2007-04-12 : 02:30:44
|
| It does work. Thank you very much! |
 |
|
|
|
|
|
|
|