Collation of common SQL statements--sql Server 2008 (query three-subquery) and GUID

Source: Internet
Author: User

--Paging data----row_number () is called window-opening function, can be paged operation

Select Row_number () over (order by ID) as Num,*from gb_data----adds a sequential num value to each column to facilitate the use of the first few data.

Select row_number () over (order by ID) as num,* from Gb_data where Num>5and num< 10--This line of code is wrong, because the system does not recognize how much num is, why?

-Because of the order of execution, the SQL statement executes the from, then executes where, and finally executes the Select

--the correct wording is as follows

Select * FROM (select row_number () over (order by ID) as num,*from   where t.num>5and t.num<

--Sub-query (query table as a condition, on the basis of a second inquiry) query all the books published in the Year of the membership of the reader information

Select*fromwhere(select from book)

The function that generates the GUID in Guid:server is newid ()

INSERT into t_table (ID) VALUES (NEWID ())

Collation of common SQL statements--sql Server 2008 (query three-subquery) and GUID

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.