sql - Reduce row duplication when multiple values exist in child records -


i have database , need generate report tables have been provided with.

however, data source query using -while in essence works fine- producing duplicates due "parameter" , "op parameter" fields (each can 1 of 2 values each unique tag).

db illustration

what take each parameter, each op parameter, , values , tag them on new fields unique tag (e.g., 'ai17611a') each tag shown once parameters.

is possible? if so, how go it?

if want new field each possible value of [op parameter] use aggregation (group by) query, e.g., sample table

[so38830066]  id  tag       parameter  op parameter --  --------  ---------  ------------  1  ai17611a  hlpr       hlop          2  ai17611a  hlpr       hhaopt        3  ai17611b  hlpr       hlop          4  ai17611c  hlpr       hhaopt       

the query

select      so38830066.tag, so38830066.parameter,      min([op parameter]='hlop') ishlop,      min([op parameter]='hhaopt') ishhaopt so38830066 group so38830066.tag, so38830066.parameter; 

produces

tag       parameter  ishlop  ishhaopt --------  ---------  ------  -------- ai17611a  hlpr           -1        -1 ai17611b  hlpr           -1         0 ai17611c  hlpr            0        -1 

you same thing multilple values of [parameter] (e.g., create [ishlpr] field) , group [tag].


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -