Explain basic SQL queries with SELECT from where Order By,
Group By-Having?
Answer Posted / swapna
Order by clause is used to sort information of a table into
specific order either ascending or descending order.
syntax:select stmt order by column;
ex:select * from emp order by sal;
Group by clause is used to divide entire group into
subgroups based on the common values columns.we can use
group by clause along with group functions.
syntax:select group by(exp 1),group by(exp 2),....from
table name group by column name;
select max(sal),min(sal) from emp group by deptno;
Group by clause can allow where clause.
Having:is used to restrict information of the atble based
on condition.
syntax:select group by (exp 1) ,group by (exp 2) from table
name group by column having (condition).
Having and Group by clauses can interchange their positions.
but when using having along with order by clause having
should be placed before order by clause.
| Is This Answer Correct ? | 25 Yes | 4 No |
Post New Answer View All Answers
Why use “pivot” in sql server?
How can you know if the row fetched from cursor is still valid in underlying table?
How to how to convert numeric expression data types using the convert() function??
What number aggregate functions are accessible there in sql?
How to create a login account in ms sql server to access the database engine using "create login" statements?
What are the advantages of user-defined functions over stored procedures in sql server?
What encryption security is available in sql azure?
How the authentication mode can be changed?
Which data types generate inaccurate results if used with an = or <> comparison in a where clause of a sql statement?
What are Row versions of DataRow?
What is sub query and its properties?
Can a table be moved to different filegroup?
What is the difference between a function and a trigger?
What is difference between aggregate and analytic function?
What is the difference between having clause and where clause in sql server?