Dark Horse Video-sub Query

Source: Internet
Author: User

Subquery: Independent subquery Dependent subquery SELECT * FROM (select Col1,col2 from TBL) as Tb1, a query results as a data source for another query, the subquery data source must be aliased as TbsSELECT * FROM (Select                    fname, Fage,fgender                 from                    mystudent                where Fage between and fgender= ' women ')As Tbswhere fname like '% Zhao '2. As a columnSelect Highest score = Select Max (score) from Tbs,minimum min. =select min (score) from Tbs,
avg. =select avg (score) from Tbs3. Query results as query criteriaSelect             * from            tblstudentwhere    tsclassid= (select Tsclassid form tblclass where className = ' high 22 shifts ')
4. Subqueries can only return a single valueSELECT * from TBLs where classId in (select ClassId from Tbs where classid= ' 4 ' or classid= ' 5 ')5, exists contained in the query found the result is exists return true, otherwise false
if (exists (SELECT * from TBL where 1<>1))
begin
print ' have result '
end
Els E
begin print ' No results '
end

SELECT * from TBL where exists (    SELECT * from TBL1 where name= ' high class 22 ' and Tbl.classid=tbl1.classid
SELECT *, Row_number () over (order by fid DESC) as number from TB
20 pages, 5 per page select * FROM (select *,row_number () over (order by FID DSC) as number from Tb
) as Tbnew where Tbnew.number between 19*5+1 and 20*5
row_number () line number
SELECT *, COUNT (*) from TBL (Error) SELECT *, COUNT (*) over () as total number of bars from TBL















From for notes (Wiz)

Dark Horse Video-sub Query

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.