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 enter image description here

enter image description here

desired output enter image description here

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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -