C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

What is Order by,compute,having,Distinct,Group by


Posted Date: 02 Sep 2007      Posted By: varma penmatsa      Member Level: Bronze     Points: 2   Responses: 2



Hiiii friends ..... i am confusing always with these Order by,compute,having,Distinct,Group by
classes in Sql Server ..can anybady please give me the definations & also differences between these..it will lot of help for me....please.....
Thanks & Regards
Varma





Responses

Author: Natarajan.M    02 Sep 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

Specifies a search condition for a group or an aggregate. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query. HAVING criteria is applied after the the grouping of rows has occurred

ORDER BY Clause :
Specifies the sort for the result set. The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.

COMPUTE Clause :
Generates totals that appear as additional summary columns at the end of the result set. When used with BY, the COMPUTE clause generates control-breaks and subtotals in the result set. You can specify COMPUTE BY and COMPUTE in the same query.

In the following example, the SELECT statement uses a simple COMPUTE clause to produce a grand total of the sum of the SubTotal and TotalDue from the SalesOrderHeader table.

SELECT CustomerID, OrderDate, SubTotal, TotalDue
FROM Sales.SalesOrderHeader
WHERE SalesPersonID = 35
ORDER BY OrderDate
COMPUTE SUM(SubTotal), SUM(TotalDue);



Author: sathiyasivam    02 Sep 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi varma

I suggest this blog

http://blog.sqlauthority.com/2007/04/17/sql-server-interview-questions-part-3/

Regards
Sathiya



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Incorrect syntax near the keyword 'inner'.
Previous : What is the distinct &situations for group by,order by........etc in Sql server
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use