How to use Select, distinct, from, where,group by, having and orderby together in SQL Server?

Posted by Sqldev under Sql Server on 4/24/2012 | Points: 10 | Views : 5035 | Status : [Member] | Replies : 2
some time we may need to use all the few of the sql commands together like Select, distinct, from, where,group by, having and orderby.

Here is an example on how to use all these commands together :

http://learnsqltips.blogspot.in/2012/04/select-distinct-from-where-group.html

Thanks & Regards,
SQL Developer,
http://learnsqltips.blogspot.in




Responses

Posted by: Ajayk3 on: 4/25/2012 [Member] Starter | Points: 25

Up
0
Down
select distinct(Team_NAME_SHORT),count(Team_NAME_SHORT) CNT From tbl_Team where team_id>20 group by TEAM_NAME_SHORT
having count(Team_NAME_SHORT)>1 order by Team_NAME_SHORT desc

Sqldev, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/20/2012 [Member] Bronze | Points: 25

Up
0
Down
SELECT * FROM SAMPLE2 WHERE S_PRICE IN (SELECT DISTINCT S_PRICE FROM SAMPLE2 GROUP BY S_PRICE HAVING
S_PRICE >25) ORDER BY S_NAME


Sqldev, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response