salut...am si eu o problema cat se poate de urgenta cu selectul asta :(
select companyname,cnt,x.LeadId from
(select count(companyname) cnt, companyname,LeadId
from (select * from LeadBase where statecode = 0)y
group by companyname)x
where x.cnt > 1
el acum afiseaza eroarea:
Server: Msg 8120, Level 16, State 1, Line 1
Column 'y.LeadId' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
pentru ca LeadId nu este in group by.....si nici nu vreau sa-l bag.....am nevoie de el doar sa mi-l afiseze.....cum evit asta...sa ma lase sa rulez scriptul fara sa-l bag in group by
multumesc mult.
sa explic si altfel ca poate nu e de ajuns pt a intelege problema
am aceasta tabela "LeadBase " in care am ceva de genul
LeadID CompanyName
1xd proepa
23d proepa
56d stizomat
eu vreau sa fac un select care sa-mi intoarca LeadID,CompanyName pentru acelea ca "proepa" deci count grupate dupa companyname sa fie >1....deci duplicate dupa Companyname