Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
huvi
Starting Member
3 Posts |
Posted - 2009-09-15 : 10:43:01
|
| I have 3 views (PagaA, PagaB and PagaC)and the 4th (PagaD) that is based on PagaA,PagaB and PagaC.It works fine.What I want now is the possibility to have the same view (like PagaD) just using the select statement instead of the objects Paga PagaB and PagaC.Is it possible?thank'sPagaD: SELECT PagaA.ID_Matricola, PagaA.Cognome, PagaA.Nome, PagaA.Data, PagaA.Cert_Medico, PagaA.TipoAttività, PagaA.Attività, PagaA.ID_Att_Iscritto, PagaB.Totale, PagaB.TipoAttività AS Expr1, PagaB.Attività AS Expr2, PagaC.Quota, PagaC.TipoAttività AS Expr3, PagaC.Attività AS Expr4FROM PagaA LEFT OUTER JOINPagaC ON PagaA.ID_Matricola = PagaC.ID_Matricola LEFT OUTER JOINPagaB ON PagaA.ID_Att_Iscritto = PagaB.ID_Att_IscrittoORDER BY PagaA.TipoAttività, PagaA.Attività, PagaA.Cognome, PagaA.Nome |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-15 : 11:02:36
|
| >>Is it possible?Yes.But rather than treat the underlying views as separate, nested, sub queries you may be able to write a single statement using just the underlying tables you need and returning just the columns you need.Be One with the OptimizerTG |
 |
|
|
huvi
Starting Member
3 Posts |
Posted - 2009-09-15 : 12:52:59
|
| Thank you for the answer.That's exactly what I want and what I'm trying ... but currently without success |
 |
|
|
huvi
Starting Member
3 Posts |
Posted - 2009-09-15 : 15:35:58
|
| Ok.I solved my problem as follow:In PagaD I wrote between () instead of view PagaA (PagaB, PagaC) the sql statement of PagaA AS Table_A , instead of PagaB sql statement of PagaB AS TABLE_B)...It works but I don't know if this is a good practice.I've tried to write a single statement (without depending Tables) but no luck because I have to extract from 1 table 2 queries with complementary Filter conditions and append the resulting columns on a third table.huvi |
 |
|
|
|
|
|
|
|