| Author |
Topic |
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-02-15 : 15:26:03
|
| is there a way to count the sort of a query and still get the values in the querycolumns1, column2, column3 are the same for 5 rows so give the values of each column and then count =5 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-15 : 15:31:25
|
| Use a subquerySELECT t1.Col1, t1.Col2, t1.Col3, (SELECT COUNT(*) FROM Table1 AS t2 ON t2.Col1 = t1.Col1 AND t2.Col2 = t1.Col2 AND t2.Col3 = t1.Col3)FROM Table1 AS t1Peter LarssonHelsingborg, Sweden |
 |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-02-15 : 15:40:27
|
| it doesnt like the ON |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-02-15 : 15:42:56
|
| Are you simply asking forselect col1,col2,col3, count(*)from yourtablegroup by col1, col2, col3... or something different? An example would help.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-02-15 : 16:23:57
|
| what peso sent worked justed need to change the on to where |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-02-15 : 16:45:25
|
quote: Originally posted by tpiazza55 what peso sent worked justed need to change the on to where
So you aren't using SQL Server? If not, you need to tell us that when you post.Tara Kizer |
 |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-02-15 : 16:56:13
|
| no im using sql2005 just didnt like that on statement |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-15 : 17:22:11
|
[code]SELECT t1.Col1, t1.Col2, t1.Col3, (SELECT COUNT(*) FROM Table1 AS t2 ON WHERE t2.Col1 = t1.Col1 AND t2.Col2 = t1.Col2 AND t2.Col3 = t1.Col3)FROM Table1 AS t1[/code] KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-15 : 17:39:51
|
| My bad. Old habit writing ON..Peter LarssonHelsingborg, Sweden |
 |
|
|
|