Can't to group by any rows from join

I have some tables and I joined them. But I need to count duplicate value in dl.order_guid and when group by, I have error Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause). What am I doing wrong?

EDITED: I need to take all field by from, and show it. but when I'm trying to take, I have null or error

    Select guid.order_guid, count(*) from (
select dl.order_guid, dn.docnumber, dn.operdate,spa.date_from,spa.date_till, lda.akcia_num,dn.balance_kod,lda.parent_id,lda.parent_baseid, dn.otsr as otrs_now, sd.otsr as otsr_f1, sd.otsrf2 as otsr_f2,count(*)
      from table1 lda
      left join table2 dn on dn.id in (1,2) and dn.baseid=3
      left join table3 sd on sd.kod_dk = dn.dk_to
      left join table4 dl on  dl.docrecno=lda.parent_id and dl.baseid=lda.parent_baseid
      left join table5 spa on spa.id=lda.akcia_num
      where lda.akcia_num=573  and lda.parent_id in (1,2) and lda.parent_baseid= 3
) guid
      group by dl.order_guid
      having count(*)>1


from Recent Questions - Stack Overflow https://ift.tt/3xcnDsO
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation