Explain basic SQL queries with SELECT from where Order By,
Group By-Having?

Answers were Sorted based on User's Feedback



Explain basic SQL queries with SELECT from where Order By, Group By-Having?..

Answer / 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

Explain basic SQL queries with SELECT from where Order By, Group By-Having?..

Answer / ranjan

In above select stmnt city must be in group by clause. Otherwise it'll sho error.

Is This Answer Correct ?    3 Yes 1 No

Explain basic SQL queries with SELECT from where Order By, Group By-Having?..

Answer / nitin

sory i m satisfied with idea.actualy i want to know is this
query is right or not.plz inform me.

SELECT country,city
FROM customers
GROUP BY country
ORDER BY city DESC

Is This Answer Correct ?    7 Yes 19 No

Post New Answer

More SQL Server Interview Questions

What do you understand by replication in sql server? Mention the different types of replication in sql server.

0 Answers  


Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?

0 Answers  


Explain filtered indexes benefits?

0 Answers  


What are the steps you should follow to start sql server in single-user mode?

0 Answers  


What is the osql utility?

0 Answers  






Why does sql studio use a single registered database repository? : sql server management studio

0 Answers  


Can we drop user if user mapped to any logins

1 Answers  


How to round a numeric value to a specific precision?

0 Answers  


What is Replication?

0 Answers  


one of my database size is 2gb and Unrestricted Growth for Data file up to 10%.But every day after day I am getting Primary Data file is full 99.999 please take appropriate actions.Why it is? Even disk space is also not full,but still I am getting the alerts.

1 Answers   Cognizant,


hi, i have a table called names and field name select * from names name a b c d i want to display like this name a,b,c,d how it is possible Regards Baiju

4 Answers  


What program is used to store the data source file?

0 Answers  


Categories