sql server - SELECTing from multiple views -


i pulling information database using views. in aforementioned views, need have layer responsible picking information views.

the views pretty large, , have same types of information in them (there few flags responsible picking correct type of information specific layer).

visualize example different layers in merchandise. pallet (view3) of items, each item wrapped in case (view2), case holds x items, , items base layer (view1).

example:

view1(single item)    view2 (multiple items)    view3 (all items) 10 cols               8 cols                    4 cols 

what's special views, of columns have same name in 3 views. column named "name" same in view1, view2 , view3, different physical layers different in amount of information that's pulled each one.

should scrap this, , put inside 1 view, , select on flags there?

the sql responsible pulling information views supposed stored procedure. input id , region code, , presented different layers item.

you haven't provided enough data

  • how 3 views built (i.e. , select from)
  • how underlying table data stored

but seems pretty standard 1:n:m relationship structure consider data structure this.

tables

items                               cases                            pallets -------------------------           -------------------              ---------------------- id        int pk not null   +------> id          int pk not null +--> id            int pk not null itemcode  nvarchar(50)      |        casebarcode nvarchar(50)    |    palletbarcode nvarchar(50) itemname  nvarchar(50)      |        palletid    fk pallets --+ caseid    fk cases ------+ 

with type of table data structure, should trivial write multiple views @ data

an item perspective

create view itemview begin      select * items end 

a case perspective

create view caseview  begin     select c.casebarcode            ,count(i.id) numitems       items join cases c on i.caseid = c.id     group c.casebarcode end 

a pallet perspective

create view palletview  begin     select p.palletbarcode            ,count(c.id) numcases       cases c join pallets p on c.palletid = p.id     group p.palletbarcode end 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -