sql - Select multiple values from two tables using horizontal relation with other table -
all experts
pardon me subject not able figure out thing else explains scenario.
i working old database has lot of crappy database issues.
table structure
table: brand
id name muid (lpmap table lpid , same rest of four) mid wid bid gid
table : lpmap lpid name asscoiate id (fk lpmapconfig)
table : lpmapconfig > id lpid datecreated
data posting images tabular representation of data
so wanted is- write sql query fetches id, name , count of (mid,meid, gid ,wid bid) if 5 have value count 5 1 of them null 4.
select name, id, case when mid not null 1 else 0 + case when meid not null 1 else 0 + case when gid not null 1 else 0 + case when wid not null 1 else 0 + case when bid not null 1 else 0 end count brand
Comments
Post a Comment