Monday, 27 May 2013

EXAMPLE OF CTE(COMMON TABLE EXPRESSION)

WITH CTE(MISSNO, MAXID) AS (SELECT        1 AS MISSNO,
                                                                                                  (SELECT        MAX(EID) AS Expr1
                                                                                                    FROM            EMP6) AS MAXID
                                                                     UNION ALL
                                                                     SELECT        MISSNO + 1 AS Expr1, MAXID
                                                                     FROM            cte AS cte_2
                                                                     WHERE        (MISSNO < MAXID))
    SELECT        MISSNO, MAXID
     FROM            CTE AS CTE_1

No comments:

Post a Comment