common table expression - SQL Server 2008R2 - WITH CTE AS disappears -
i have table owner names , multiple addresses. want select 1 address , doesn't matter 1 gets pulled long 1.
i've created view syntax below , have nested in view.
with cte ( select distinct ownerlesseeid, addressid, row_number() on (partition ownerlesseeid order ownerlesseeid) ol ownerlesseeaddress) select distinct ownerlesseeid, addressid, ol cte ol = 1
it runs , executes desired. however, every time save , close view cte ( disappears. whenever re-open have insert in part again execute query.
according to: https://msdn.microsoft.com/en-us/library/ms175972(v=sql.105).aspx temporary expression.
i don't think can use max() because ownerlesseeid uniqueid field. ideas on how mitigate problem?
Comments
Post a Comment