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 |
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-02-23 : 09:34:32
|
Ok, trying to slowly piece together a complicated sql and here's one piece of the puzzle.Let's say in tblA and in fldA I have the entries:xxxyyzzzI want to count the number of x's, y's, and z's and return all that info in one sql statement.But, later, there may be added in the field other letters, so it needs to be dynamic and return something like:x 3y 2z 3Counting one item is easy, but never thought about counting all distint items.Thanks,Zath |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-23 : 09:37:28
|
How difficult is this?Select fldA, count(fldA) as [count]From TblAGroup by fldA Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-02-23 : 09:45:53
|
Knew it had to be something simple!Thanks,Zath |
 |
|
|
|
|