Need Query for this
-
I am using sql server 2005. I have a table like this
COL1 COL2
A 1
A 1
B 2
C 1
C 2and i need output like this
COL1 COL2 No:
A 1 2
B 2 1
C 1 1
C 2 1How many times the same COL1 and COL2 coming, that should be the column NO: in the output.. Please not that here i dont have any inputs like A,1 etc.... This is just the pattern, so i need a general quesry.
My small attempt...
-
I am using sql server 2005. I have a table like this
COL1 COL2
A 1
A 1
B 2
C 1
C 2and i need output like this
COL1 COL2 No:
A 1 2
B 2 1
C 1 1
C 2 1How many times the same COL1 and COL2 coming, that should be the column NO: in the output.. Please not that here i dont have any inputs like A,1 etc.... This is just the pattern, so i need a general quesry.
My small attempt...
What you need is a very simple select statement using grouping.
select Col1, Col2, count(col1) as No
from tablename
group by Col1, Col2
order by Col1, Col2Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010
-
I am using sql server 2005. I have a table like this
COL1 COL2
A 1
A 1
B 2
C 1
C 2and i need output like this
COL1 COL2 No:
A 1 2
B 2 1
C 1 1
C 2 1How many times the same COL1 and COL2 coming, that should be the column NO: in the output.. Please not that here i dont have any inputs like A,1 etc.... This is just the pattern, so i need a general quesry.
My small attempt...
hi all...... i got the solution... i think we can use the same technique which use for duplicate checking
SELECT COL1, COL2, count(*)
FROM table
GROUP BY COL1, COL2i think this is fine
My small attempt...
-
hi all...... i got the solution... i think we can use the same technique which use for duplicate checking
SELECT COL1, COL2, count(*)
FROM table
GROUP BY COL1, COL2i think this is fine
My small attempt...
Wow, looks remarkably like the answer I gave you 6 mins ago... ;-)
Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010
-
What you need is a very simple select statement using grouping.
select Col1, Col2, count(col1) as No
from tablename
group by Col1, Col2
order by Col1, Col2Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010
you are great
My small attempt...
-
Wow, looks remarkably like the answer I gave you 6 mins ago... ;-)
Knowledge is knowing that the tomato is a fruit. Wisdom is not putting it in fruit salad!! Booger Mobile - Camp Quality esCarpade 2010
i seen your comment after i post my... anyway thanks... :-D
My small attempt...