LEFT JOIN with CASE subquery ?

  • usererror - Tuesday, July 24, 2018 7:31 AM

    Steve,
    This may be a silly question, but what is the significance of '_LIMITED' that you appended to the original table name "INS4" so it was 'INS4_LIMITED' on the subquery you made containing the WITH clause?
    Thanks,
    Mark

    INS4_LIMITED is the name he gave to the result set returned by the CTE so that he could reference later in the query.  It could have been named ANYTHING, but it's a common practice to have self documenting code including having names that are indicative of what the object represents.  In this case, the CTE returns a limited set of rows from the INS4 table, hence the self-documenting name of INS4_LIMITED.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • drew.allen - Tuesday, July 24, 2018 8:25 AM

    INS4_LIMITED is the name he gave to the result set returned by the CTE so that he could reference later in the query.  It could have been named ANYTHING, but it's a common practice to have self documenting code including having names that are indicative of what the object represents.  In this case, the CTE returns a limited set of rows from the INS4 table, hence the self-documenting name of INS4_LIMITED.

    Drew

    Thank you.

    -Mark
    MSSQL 2019 Standard, Azure Hosted. Techie/Sysadmin by trade; Three years as a "DBA" now.

  • drew.allen - Tuesday, July 24, 2018 8:25 AM

    usererror - Tuesday, July 24, 2018 7:31 AM

    Steve,
    This may be a silly question, but what is the significance of '_LIMITED' that you appended to the original table name "INS4" so it was 'INS4_LIMITED' on the subquery you made containing the WITH clause?
    Thanks,
    Mark

    INS4_LIMITED is the name he gave to the result set returned by the CTE so that he could reference later in the query.  It could have been named ANYTHING, but it's a common practice to have self documenting code including having names that are indicative of what the object represents.  In this case, the CTE returns a limited set of rows from the INS4 table, hence the self-documenting name of INS4_LIMITED.

    Drew

    Thanks for providing that perfect explanation of my code.   I've been crazy busy at work for the last few days, so it's nice to know others can fill in the gaps this way.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply