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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Group By Query with sum

Author  Topic 

san3297
Starting Member

7 Posts

Posted - 2010-08-10 : 13:47:42
I have a table with data as follows
CON1 TYPE
1 R1
1 R2
2 R3
2 Z1
2 Z2
3 Y1
3 Y2

I dont have unique column to distinguish types of same origin(R,Z,Y).
What i am looking for is to get data

CON1 TYPE
4 R
4 Z
6 Y

Let me know if some one can guide with this query.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-10 : 14:04:38
[code]
SELECT SUM(CON1) AS CON1,LEFT(TYPE,1) AS TYPE
FROM Table
GROUP BY LEFT(TYPE,1)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -