Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
andimanro
Starting Member
2 Posts |
Posted - 2010-08-31 : 23:40:22
|
| Dear All..I have a table named tProduk with data like this :---------Name |---------Monitor |Monitor |Mouse |Mouse |Keyboard|what sql script should i use to make the result like this from the table tProduk :-----------------Product | Count |-----------------Monitor | 2 |Mouse | 2 |Keyboard| 1 |thnx in advance |
|
|
matty
Posting Yak Master
161 Posts |
Posted - 2010-09-01 : 02:32:36
|
| [code]SELECT Name,COUNT(Name) AS CountFROM tProduk GROUP BY Name[/code] |
 |
|
|
maevr
Posting Yak Master
169 Posts |
Posted - 2010-09-01 : 02:35:27
|
| Hi!You should always try to give us more info about the table.Solution:select Name, COUNT(Name) as COUNT from tProdukgroup by Name order by COUNT descOutput:Monitor 2Mouse 2Keyboard 1 |
 |
|
|
maevr
Posting Yak Master
169 Posts |
Posted - 2010-09-01 : 02:36:47
|
| Sorry about that, Matty posted his script before me :-). |
 |
|
|
andimanro
Starting Member
2 Posts |
Posted - 2010-09-01 : 03:31:59
|
| dear maevr and matty..thanks for your reply... it works... thanks again :) |
 |
|
|
|
|
|