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 |
tuka
Starting Member
26 Posts |
Posted - 2006-06-14 : 09:00:21
|
I am trying to get a recordset that gives me along with the id and count, the name (from another table) of a tradelead. Each time I reference a column from the other table, it breaks... I think I understand why but I am at a loss to figure out a solution.. any sugestions ? THIS WORKS: SELECT COUNT(tb_industry.id_industry) AS tlcount, tb_industry.id_industry FROM tb_tradelead INNER JOIN tb_industry ON tb_tradelead.id_industry=tb_industry.id_industry GROUP BY tb_industry.id_industry BIT THIS FAILS.... SELECT COUNT(tb_industry.id_industry) AS tlcount, tb_industry.id_industry, tb_industry.name FROM tb_tradelead INNER JOIN tb_industry ON tb_tradelead.id_industry=tb_industry.id_industry GROUP BY tb_industry.id_industry Server message Column 'tb_industry.name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. TIA, tuka |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-14 : 09:18:53
|
You should include that column in Group by ClauseSELECT COUNT(tb_industry.id_industry) AS tlcount, tb_industry.id_industry, tb_industry.name FROM tb_tradelead INNER JOIN tb_industry ON tb_tradelead.id_industry=tb_industry.id_industry GROUP BY tb_industry.id_industry,tb_industry.name MadhivananFailing to plan is Planning to fail |
|
|
tuka
Starting Member
26 Posts |
Posted - 2006-06-14 : 09:33:03
|
Thanks, that did it ! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|