Sunday, 25 November 2012

0 How To Use Subqueries In SQL


Introduction
In this article I am going to explain how to use Subqueries in SQL. A select statement known as subquery if it is codded within another SQL statement. Subquery can return a single value or a result set. This result set may contain a single column or more than one column.
There are four way to create subquery  in a SELECT statement.
  • In WHERE Clause
  • In HAVING Clause
  • In FROM Clause
  • In SELECT Clause
Example
select * from mcninvoices
where invoicetotal >
( select avg(invoicetotal) from invoices )
Output  
Clipboard14.jpg
Source : http://www.dotnetheaven.com/article/how-to-use-subqueries-in-sql

0 comments:

Post a Comment

 

My MSSQL Search Collections Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates