-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: srkrishnakumar
Message 3 in Discussion
A self-join is a query in which a table is joined (compared) to itself.
Self-joins are used to compare values in a column with other values in the same
column in the same table. One practical use for self-joins: obtaining running
counts and running totals in an SQL query. <o:p></o:p>
<o:p>
To write the query, select from the same table listed twice with different
aliases, set up the comparison, and eliminate cases where a particular value
would be equal to itself.<o:p></o:p>
<o:p> </o:p>
Example<o:p></o:p>
<o:p></o:p>
Which customers are located in the same state (column name is Region)? Type
this statement in the SQL window:<o:p></o:p>
<o:p> </o:p>
SELECT DISTINCT c1.ContactName, c1.Address, c1.City,
c1.Region<o:p></o:p>
FROM Customers AS c1, Customers AS c2<o:p></o:p>
WHERE c1.Region = c2.Region<o:p></o:p>
AND c1.ContactName <> c2.ContactName<o:p></o:p>
ORDER BY c1.Region, c1.ContactName;
</o:p>
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]