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 |
itmaster
Starting Member
28 Posts |
Posted - 2013-08-13 : 08:28:14
|
Hi,They want me to write a nested view and I canot find an example anywhere. Can someomne show me one please.Thnk you |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-13 : 08:31:15
|
create view dbo.View1 AS select 1 as ColumnNameGocreate view dbo.View2 as select ColumnName, 2 * columnname AS TwiceColumnName from dbo.view1goselect * from dbo.view2go Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
itmaster
Starting Member
28 Posts |
Posted - 2013-08-13 : 09:45:11
|
Thanks for the help and this ias my fault, but this is nto what I mean. They call it view but it isn't. It is is something like this:select *from t1 Inner join ( Select Max(val)... Inner join ( SQL statement Union SQL statement ) vi1 ....This is not exact code, because that is what I am looking for I do not know how to do the nested vi1s?the code I |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-08-13 : 09:48:45
|
Do you mean something like this?CREATE TABLE #A (id INT, val FLOAT);CREATE TABLE #B (id INT, val FLOAT);SELECT *FROM( SELECT id, MAX(val) AS MaxValA FROM #A ) aINNER JOIN( SELECT id, MAX(val) AS MaxValB FROM #B UNION ALL SELECT id, MAX(val) FROM #A) b ON a.id = b.id;DROP TABLE #A;DROP TABLE #b; |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-13 : 09:49:55
|
You mean a derived table? Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2013-08-13 : 10:11:44
|
That is, as Peso said, a derived table. Sometimes is it also called an inline-view. |
|
|
|
|
|
|
|