CTEs basically let you create a pseudo table to query from within a query. I
use them for deduplicating records usually with the ROW_NUMBER() function.
WITH myCTE AS
(
SELECT
Col1,
Col2,
Col3
FROM
T1
)
SELECT
X,
Y,
cte.Col1,
cte.Col2
FROM
myTable
INNER JOIN myCTE ON myTable.Z = myCTE.Col3
Thanks,
Brian Desmond
[email protected]
w - 312.625.1438 | c - 312.731.3132
-----Original Message-----
From: Ben Scott [mailto:[email protected]]
Sent: Wednesday, January 04, 2012 7:20 PM
To: NT System Admin Issues
Subject: Re: SQL Coding help
On Wed, Jan 4, 2012 at 5:49 PM, Jeff Steward <[email protected]> wrote:
> I did the free consulting already :)
>
> Common Table Expressions to the rescue.
See, now, I regard that as unfortunate. I don't know what Common Table
Expressions are, and this could have been a learning experience for me.
-- Ben
~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin