944,087 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 3478
  • MS SQL RSS
Jul 7th, 2006
0

Need Help on SQL Query for select statement

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newMeg is offline Offline
21 posts
since Jul 2006
Jul 7th, 2006
0

Re: Need Help on SQL Query for select statement

MS SQL Syntax (Toggle Plain Text)
  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.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Jul 9th, 2006
0

Re: Need Help on SQL Query for select statement

Hi hollystyles,

thanx for the great help.It works.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newMeg is offline Offline
21 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Setting Roles and Users in MS SQL
Next Thread in MS SQL Forum Timeline: Help Editing Trigs, Stored Procs, and Fkeys





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC