What is the 't' mean at end of the subquery in SQL Server



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have following code used for query data by rows and start point:



SELECT InquiryId
FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
from [InquiryTable] WITH(NOLOCK)
where InquiryId >= 100 and InquiryId <= 200)t
where Seq Between 1 and 20


What is character 't' means at the end of the forth row in SQL server?



Thanks










share|improve this question

















  • 3





    t is an alias for the sub-query. it can be anything other than a reserved keyword

    – Vamsi Prabhala
    Nov 15 '18 at 16:05











  • I can't find a canonical Q&A for SQL Server aliases, but this should help stackoverflow.com/questions/4981481/… or stackoverflow.com/questions/198196/when-to-use-sql-table-alias

    – DavidG
    Nov 15 '18 at 16:07


















1















I have following code used for query data by rows and start point:



SELECT InquiryId
FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
from [InquiryTable] WITH(NOLOCK)
where InquiryId >= 100 and InquiryId <= 200)t
where Seq Between 1 and 20


What is character 't' means at the end of the forth row in SQL server?



Thanks










share|improve this question

















  • 3





    t is an alias for the sub-query. it can be anything other than a reserved keyword

    – Vamsi Prabhala
    Nov 15 '18 at 16:05











  • I can't find a canonical Q&A for SQL Server aliases, but this should help stackoverflow.com/questions/4981481/… or stackoverflow.com/questions/198196/when-to-use-sql-table-alias

    – DavidG
    Nov 15 '18 at 16:07














1












1








1








I have following code used for query data by rows and start point:



SELECT InquiryId
FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
from [InquiryTable] WITH(NOLOCK)
where InquiryId >= 100 and InquiryId <= 200)t
where Seq Between 1 and 20


What is character 't' means at the end of the forth row in SQL server?



Thanks










share|improve this question














I have following code used for query data by rows and start point:



SELECT InquiryId
FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
from [InquiryTable] WITH(NOLOCK)
where InquiryId >= 100 and InquiryId <= 200)t
where Seq Between 1 and 20


What is character 't' means at the end of the forth row in SQL server?



Thanks







sql sql-server subquery






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 16:04









Zeqing ZhangZeqing Zhang

1,41021424




1,41021424







  • 3





    t is an alias for the sub-query. it can be anything other than a reserved keyword

    – Vamsi Prabhala
    Nov 15 '18 at 16:05











  • I can't find a canonical Q&A for SQL Server aliases, but this should help stackoverflow.com/questions/4981481/… or stackoverflow.com/questions/198196/when-to-use-sql-table-alias

    – DavidG
    Nov 15 '18 at 16:07













  • 3





    t is an alias for the sub-query. it can be anything other than a reserved keyword

    – Vamsi Prabhala
    Nov 15 '18 at 16:05











  • I can't find a canonical Q&A for SQL Server aliases, but this should help stackoverflow.com/questions/4981481/… or stackoverflow.com/questions/198196/when-to-use-sql-table-alias

    – DavidG
    Nov 15 '18 at 16:07








3




3





t is an alias for the sub-query. it can be anything other than a reserved keyword

– Vamsi Prabhala
Nov 15 '18 at 16:05





t is an alias for the sub-query. it can be anything other than a reserved keyword

– Vamsi Prabhala
Nov 15 '18 at 16:05













I can't find a canonical Q&A for SQL Server aliases, but this should help stackoverflow.com/questions/4981481/… or stackoverflow.com/questions/198196/when-to-use-sql-table-alias

– DavidG
Nov 15 '18 at 16:07






I can't find a canonical Q&A for SQL Server aliases, but this should help stackoverflow.com/questions/4981481/… or stackoverflow.com/questions/198196/when-to-use-sql-table-alias

– DavidG
Nov 15 '18 at 16:07













3 Answers
3






active

oldest

votes


















5














Here is a helpful visual showing how t is an alias:



SELECT *
FROM table t


Replace table with a subquery:



SELECT *
FROM (SELECT * FROM table) t





share|improve this answer






























    4














    It is an alias for your subquery. Improved indentation helps you to understand better:



    SELECT InquiryId
    FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
    from [InquiryTable] WITH(NOLOCK)
    where InquiryId >= 100
    and InquiryId <= 200
    ) AS t
    where Seq Between 1 and 20





    share|improve this answer






























      -1














      doesn't mean matter, you are renaming the table in the subquery as t, but in from to rename you mustn't use as, but you must use directly the name in the table, and you can require the columns of the table or the subquery in you case using t.col






      share|improve this answer




















      • 1





        The subquery is named not any table in it.

        – alk
        Nov 15 '18 at 16:41












      • I have corrected, however it works with subquery and with table

        – David Marabottini
        Nov 15 '18 at 16:46











      • Perhaps a language issue? Still, I do not see any significant changes in your answer.

        – alk
        Nov 15 '18 at 18:56












      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323405%2fwhat-is-the-t-mean-at-end-of-the-subquery-in-sql-server%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      Here is a helpful visual showing how t is an alias:



      SELECT *
      FROM table t


      Replace table with a subquery:



      SELECT *
      FROM (SELECT * FROM table) t





      share|improve this answer



























        5














        Here is a helpful visual showing how t is an alias:



        SELECT *
        FROM table t


        Replace table with a subquery:



        SELECT *
        FROM (SELECT * FROM table) t





        share|improve this answer

























          5












          5








          5







          Here is a helpful visual showing how t is an alias:



          SELECT *
          FROM table t


          Replace table with a subquery:



          SELECT *
          FROM (SELECT * FROM table) t





          share|improve this answer













          Here is a helpful visual showing how t is an alias:



          SELECT *
          FROM table t


          Replace table with a subquery:



          SELECT *
          FROM (SELECT * FROM table) t






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 16:08









          Aaron DietzAaron Dietz

          8,6121924




          8,6121924























              4














              It is an alias for your subquery. Improved indentation helps you to understand better:



              SELECT InquiryId
              FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
              from [InquiryTable] WITH(NOLOCK)
              where InquiryId >= 100
              and InquiryId <= 200
              ) AS t
              where Seq Between 1 and 20





              share|improve this answer



























                4














                It is an alias for your subquery. Improved indentation helps you to understand better:



                SELECT InquiryId
                FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
                from [InquiryTable] WITH(NOLOCK)
                where InquiryId >= 100
                and InquiryId <= 200
                ) AS t
                where Seq Between 1 and 20





                share|improve this answer

























                  4












                  4








                  4







                  It is an alias for your subquery. Improved indentation helps you to understand better:



                  SELECT InquiryId
                  FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
                  from [InquiryTable] WITH(NOLOCK)
                  where InquiryId >= 100
                  and InquiryId <= 200
                  ) AS t
                  where Seq Between 1 and 20





                  share|improve this answer













                  It is an alias for your subquery. Improved indentation helps you to understand better:



                  SELECT InquiryId
                  FROM (select InquiryId, ROW_NUMBER() over (order by InquiryId) as Seq
                  from [InquiryTable] WITH(NOLOCK)
                  where InquiryId >= 100
                  and InquiryId <= 200
                  ) AS t
                  where Seq Between 1 and 20






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 16:07









                  Eray BalkanliEray Balkanli

                  4,65852347




                  4,65852347





















                      -1














                      doesn't mean matter, you are renaming the table in the subquery as t, but in from to rename you mustn't use as, but you must use directly the name in the table, and you can require the columns of the table or the subquery in you case using t.col






                      share|improve this answer




















                      • 1





                        The subquery is named not any table in it.

                        – alk
                        Nov 15 '18 at 16:41












                      • I have corrected, however it works with subquery and with table

                        – David Marabottini
                        Nov 15 '18 at 16:46











                      • Perhaps a language issue? Still, I do not see any significant changes in your answer.

                        – alk
                        Nov 15 '18 at 18:56
















                      -1














                      doesn't mean matter, you are renaming the table in the subquery as t, but in from to rename you mustn't use as, but you must use directly the name in the table, and you can require the columns of the table or the subquery in you case using t.col






                      share|improve this answer




















                      • 1





                        The subquery is named not any table in it.

                        – alk
                        Nov 15 '18 at 16:41












                      • I have corrected, however it works with subquery and with table

                        – David Marabottini
                        Nov 15 '18 at 16:46











                      • Perhaps a language issue? Still, I do not see any significant changes in your answer.

                        – alk
                        Nov 15 '18 at 18:56














                      -1












                      -1








                      -1







                      doesn't mean matter, you are renaming the table in the subquery as t, but in from to rename you mustn't use as, but you must use directly the name in the table, and you can require the columns of the table or the subquery in you case using t.col






                      share|improve this answer















                      doesn't mean matter, you are renaming the table in the subquery as t, but in from to rename you mustn't use as, but you must use directly the name in the table, and you can require the columns of the table or the subquery in you case using t.col







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 15 '18 at 16:45

























                      answered Nov 15 '18 at 16:17









                      David MarabottiniDavid Marabottini

                      1707




                      1707







                      • 1





                        The subquery is named not any table in it.

                        – alk
                        Nov 15 '18 at 16:41












                      • I have corrected, however it works with subquery and with table

                        – David Marabottini
                        Nov 15 '18 at 16:46











                      • Perhaps a language issue? Still, I do not see any significant changes in your answer.

                        – alk
                        Nov 15 '18 at 18:56













                      • 1





                        The subquery is named not any table in it.

                        – alk
                        Nov 15 '18 at 16:41












                      • I have corrected, however it works with subquery and with table

                        – David Marabottini
                        Nov 15 '18 at 16:46











                      • Perhaps a language issue? Still, I do not see any significant changes in your answer.

                        – alk
                        Nov 15 '18 at 18:56








                      1




                      1





                      The subquery is named not any table in it.

                      – alk
                      Nov 15 '18 at 16:41






                      The subquery is named not any table in it.

                      – alk
                      Nov 15 '18 at 16:41














                      I have corrected, however it works with subquery and with table

                      – David Marabottini
                      Nov 15 '18 at 16:46





                      I have corrected, however it works with subquery and with table

                      – David Marabottini
                      Nov 15 '18 at 16:46













                      Perhaps a language issue? Still, I do not see any significant changes in your answer.

                      – alk
                      Nov 15 '18 at 18:56






                      Perhaps a language issue? Still, I do not see any significant changes in your answer.

                      – alk
                      Nov 15 '18 at 18:56


















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323405%2fwhat-is-the-t-mean-at-end-of-the-subquery-in-sql-server%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kleinkühnau

                      Makov (Slowakei)

                      Deutsches Schauspielhaus