| | |
Need Help on SQL Query for select statement
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2006
Posts: 21
Reputation:
Solved Threads: 0
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
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
MS SQL Syntax (Toggle Plain Text)
SELECT top 1 area, countarea FROM( SELECT area, count(area) countarea FROM callers GROUP BY area ) areacount ORDER BY countarea DESC
Last edited by hollystyles; Jul 7th, 2006 at 8:36 am.
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- how to delete duplicate record in a table by using SQL query (MS SQL)
- Hi,Need help on sql select statement structure (MS SQL)
- SQL Query - rarely issue (ASP.NET)
- C# VS 2005 - SQL Query Parameters to an ODBC DataSource (C#)
- sql query updating problem (Visual Basic 4 / 5 / 6)
- Please help me out with MySQL query (MySQL)
- PHP/SQL query help (PHP)
- Program Problem with a select statement to access Data base (C)
Other Threads in the MS SQL Forum
- Previous Thread: Setting Roles and Users in MS SQL
- Next Thread: Help Editing Trigs, Stored Procs, and Fkeys
| Thread Tools | Search this Thread |
Tag cloud for MS SQL
"last autogrowth business connectingtodatabaseinuse count cursor data database dateadd datepart day" dbsize deadlock delete_trigger getdate highperformancecomputing hpc hpcserver2008 ibm iis loop maximum microsoft ms mssql multiple multithreading news number permission query reporting result server services sets source sql sqlserver sqlserver2005 supercomputing tables uniqueid update view weekday






