Need Help on SQL Query for select statement

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2006
Posts: 21
Reputation: newMeg is an unknown quantity at this point 
Solved Threads: 0
newMeg newMeg is offline Offline
Newbie Poster

Need Help on SQL Query for select statement

 
0
  #1
Jul 7th, 2006
Hi,I'm new to daniweb forum. I hope someone could help.

I have a table called Caller which has a field called Area. I need to select the value of the record in this field that repeats the most. For example

Area
Sel
KL
Sel
Sel
Pen
KL

which means i want the answer as Sel because Sel is the higest number that repeated in the Area Column which is three(3) times. KL repeated twice and Pen once. I want to be able to write an SQL statement that could do this.

Can someone help pls. I've tried max but it didnt work. Thank you
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Need Help on SQL Query for select statement

 
0
  #2
Jul 7th, 2006
  1. SELECT top 1
  2. area, countarea
  3. FROM(
  4.  
  5. SELECT
  6. area, count(area) countarea
  7. FROM
  8. callers
  9. GROUP BY
  10. area
  11.  
  12. ) areacount
  13.  
  14. ORDER BY
  15. countarea DESC
Last edited by hollystyles; Jul 7th, 2006 at 8:36 am.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 21
Reputation: newMeg is an unknown quantity at this point 
Solved Threads: 0
newMeg newMeg is offline Offline
Newbie Poster

Re: Need Help on SQL Query for select statement

 
0
  #3
Jul 9th, 2006
Hi hollystyles,

thanx for the great help.It works.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC