sql server - Select all columns when using INNER JOIN -
this question has answer here:
i have sql code :
select tb_dataproperti.*, tbl_rating.isnull(avg(rating), 0) averagerating tb_dataproperti inner join tbl_rating on tb_dataproperti.kode_properti = tbl_rating.kode_properti group tb_dataproperti.judullisting order averagerating desc
i error:
msg 8120, level 16, state 1, line 3
column 'tb_dataproperti.kode_properti' invalid in select list because not contained in either aggregate function or group clause.
i want select data columns using *
, because have many columns
problem trying use aggregate function of 1 table , group on table.the rule if using aggregate function column column should use in group by.still try hope useful.
select tb_dataproperti.*, isnull(avg(tbl_rating.rating), 0) on (partition tbl_rating.kode_properti) averagerating tb_dataproperti inner join tbl_rating on tb_dataproperti.kode_properti = tbl_rating.kode_properti order averagerating desc
wiki
Comments
Post a Comment