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 2005 Forums
 Transact-SQL (2005)
 help me query

Author  Topic 

niyaz4872
Starting Member

41 Posts

Posted - 2011-10-17 : 06:03:50
following is my table structure

SuitDtl_KALA_ID,Suit_Id,SuitDtl_Qty,SuitDtl_Qty_jayeze
1513215191 151390000297 1.000 0.000
1513215192 151390000297 3.000 0.000
1513215193 151390000297 1.000 0.000
1513207151 151390000297 2.000 0.000
1513207152 151390000297 3.000 0.000
1513207153 151390000297 1.000 0.000
1513217103 151390000297 5.000 0.000
1513215193 151390000297 0.000 1.000
1513207151 151390000297 0.000 1.000
1513217103 151390000297 0.000 1.000

following is sample results i wan't

SuitDtl_KALA_ID,Suit_Id,SuitDtl_Qty,SuitDtl_Qty_jayeze
151390000297 1513207151 2.000 1.000
151390000297 1513207152 3.000 0
151390000297 1513207153 1.000 0
151390000297 1513215191 1.000 0
151390000297 1513215192 3.000 0
151390000297 1513215193 1.000 1.000
151390000297 1513217103 5.000 1.000



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-17 : 08:01:39
can you tell me rule based on which you think you will get the above result?

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

Go to Top of Page

niyaz4872
Starting Member

41 Posts

Posted - 2011-10-17 : 08:29:31
following is my table structure

SuitDtl_KALA_ID,Suit_Id,SuitDtl_Qty,SuitDtl_Qty_jayeze
1513207151 151390000297 2.000 0.000
1513207151 151390000297 0.000 1.000
1513217103 151390000298 0.000 2.000
1513217103 151390000298 7.000 0.000

following is sample results i wan't

SuitDtl_KALA_ID,Suit_Id,SuitDtl_Qty,SuitDtl_Qty_jayeze
151390000297 1513207151 2.000 1.000
151390000298 1513217103 7.000 2.000

i want to merge these two rows with this rule ,if these(SuitDtl_KALA_ID,Suit_Id) filed value has same data make result it as a one row and sum these (SuitDtl_Qty,SuitDtl_Qty_jayeze)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-17 : 08:33:31
[code]
SELECT SuitDtl_KALA_ID,Suit_Id,
SUM(SuitDtl_Qty) AS SuitDtl_Qty,
SUM(SuitDtl_Qty_jayeze) AS SuitDtl_Qty_jayeze
FROM table
GROUP BY SuitDtl_KALA_ID,Suit_Id
[/code]

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

Go to Top of Page

niyaz4872
Starting Member

41 Posts

Posted - 2011-10-17 : 08:54:37
tnx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-17 : 09:01:49
wc

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

Go to Top of Page
   

- Advertisement -