SELECT <Column Name>, NumberOfTimes=COUNT(<Column Name>) FROM TableName
GROUP BY <Column Name>
ORDER BY <Column Name> DESC
we get sample result as
UsrID NumberOfTimes
------ -------------
28472 10
28467 4
27552 1
24426 12
SQL SERVER – Count Duplicate Records or Count Repeated Values (like a name comes two or more times)
Posted by PratheesLabels: Sql-Server
Overview
download
ASP.NET MVC 1.0 provides a new Model-View-Controller (MVC) framework on top of the existing ASP.NET 3.5 runtime. This means that developers can take advantage of the MVC design patterns to create their Web Applications which includes the ability to achieve and maintain a clear separation of concerns (the UI or view from the business and application logic and backend data), as well as facilitate test driven development (TDD). The ASP.NET MVC framework defines a specific pattern to the Web Application folder structure and provides a controller base-class to handle and process requests for “actions”. Developers can take advantage of the specific Visual Studio 2008 MVC templates within this release to create their Web applications, which includes the ability to select a specific Unit Test structure to accompany their Web Application development.
The MVC framework is fully extensible at all points, allowing developers to create sophisticated structures that meet their needs, including for example Dependency Injection (DI) techniques, new view rendering engines or specialized controllers.
As the ASP.NET MVC framework is built on ASP.NET 3.5, developers can take advantage of many existing ASP.NET 3.5 features, such as localization, authorization, Profile etc.n
Labels: .NET 4.0
Labels: Books
The most frequently used wildcard is the percent sign (%).
Within a search string, % means match any number of occurrences of any character.
Before we proceed it further lets create a table Dev_Products having two columns.
Create Table Dev_Products
(
Prod_ID Int,
Prod_Name Varchar(255)
)
Inserting some values.
Insert Into Dev_Products (Prod_ID,Prod_Name)Values(1,'DevProd1')
Go
Insert Into Dev_Products(Prod_ID,Prod_Name)Values(2,'DevProd2')
Go
Insert Into Dev_Products(Prod_ID,Prod_Name)Values(3,'Plaza101')
Go
Insert Into Dev_Products(Prod_ID,Prod_Name)Values(4,'Coupon Park')
GO
Insert Into Dev_Products(Prod_ID,Prod_Name)Values(5,'Imate KJam')
For example, to find all products that start with the word ‘dev’, you can issue the following SELECT statement
SELECT
Prod_ID,
Prod_Name
FROM
Dev_Products
WHERE
Prod_name LIKE 'Dev%'
Output
Prod_ID Prod_Name
----------------------
1 DevProd1
2 DevProd2
(2 row(s) affected)
The % tells Sql Server to accept any characters values after the word “dev”.
Wildcard can be used first or middle or any part of the search pattern.
A rare case of wildcard is in the middle.
SELECT
Prod_ID,
Prod_Name
FROM
Dev_Products
WHERE
Prod_name LIKE 'D%1'
Prod_ID Prod_Name
-------------------------------------------------------
1 DevProd1
Mean search all the products which start from D and end with d.
The Underscore (_) Wildcard
Another useful wildcard is underscore, it works same way like % but it will match only a single charater.
For Example
SELECT
Prod_ID,
Prod_Name
FROM
Dev_Products
WHERE
Prod_name LIKE '_oupon%'
Output
Prod_ID Prod_Name
--------------------------
4 Coupon Park
(1 row(s) affected)
The Brackets ([ ]) Wildcard
The set of characters specified between brackets wildcard which will match any one characters in the specified position (the location of the wildcard).
SELECT
Prod_ID,
Prod_Name
FROM
Dev_Products
WHERE
Prod_name LIKE '[p1]%'
Output
Prod_ID Prod_Name
-------------------------------
3 Plaza101
Brackets [] wildcard will match the charaters begins with P and end with 1.
The Brackets (^) Wildcard
Any single character not within the specified range ([^a-f]) or set ([^abcdef])
SELECT
Prod_ID,
Prod_Name
FROM
Dev_Products
WHERE
Prod_name LIKE '[^Dev]%'
Output
Prod_ID Prod_Name
----------- ------------------------
3 Plaza101
4 Coupon Park
5 Imate KJam
(3 row(s) affected)
Any charaters started with “Dev” will be excluded.
Labels: Sql-Server