13,048,406 members (147,793 online)
Rate this:
See more:
Hi
I want sum of two Same Columns.
My Query is as Follows

```SELECT  OMTC,OMYY,OMNO,ODSR,OMCMCD,OMLMGCST,ODSALPRC,ORRMCTG,SUM(ORSALVAL) as total
FROM ORDMST INNER JOIN ORDDSG ON OMTC=ODTC AND OMYY=ODYY AND OMCHR=ODCHR AND OMNO=ODNO
INNER JOIN ORDRM ON ODTC=ORTC AND ODYY=ORYY AND ODCHR=ORCHR AND ODNO=ORNO AND ODSR=ORSR
where  omtc='qt' and omyy='13' and omchr='KPS' and omno='174' AND ODSR=2 AND ORRMCTG NOT IN ('d','C')
GROUP BY ODSR,ORRMCTG,OMTC,OMYY,OMNO,OMCMCD,OMLMGCST,ODSALPRC```

Result :
QT 13 174 2 KP029 1500 98.53 S 3.942
QT 13 174 2 KP029 1500 98.53 X 9.072

Expected Result :
QT 13 174 2 KP029 1500 98.53 13.014
Posted 29-Apr-13 19:07pm
OriginalGriff 30-Apr-13 1:16am

This is not a good question - we cannot work out from that little what you are trying to do.
Use the "Improve question" widget to edit your question and provide better information.

Try removing ORRMCTG from ORDER BY.
Member 9799439 30-Apr-13 5:53am

Yep Sure.Next time i will improve my question.

Rate this:

## Solution 1

Remove ORRMCTG column from your query and you'll get desired results.
```SELECT  OMTC
,OMYY
,OMNO
,ODSR
,OMCMCD
,OMLMGCST
,ODSALPRC
,SUM(ORSALVAL) as total
FROM ORDMST
INNER JOIN ORDDSG ON OMTC=ODTC AND OMYY=ODYY AND OMCHR=ODCHR AND OMNO=ODNO
INNER JOIN ORDRM ON ODTC=ORTC AND ODYY=ORYY AND ODCHR=ORCHR AND ODNO=ORNO AND ODSR=ORSR

WHERE omtc='qt' AND omyy='13' AND omchr='KPS' AND omno='174' AND ODSR=2
AND ORRMCTG NOT IN ('d','C')
GROUP BY ODSR,OMTC,OMYY,OMNO,OMCMCD,OMLMGCST,ODSALPRC```
Member 9799439 30-Apr-13 5:53am

@Oshtri Deka : Thank You So Much.

Top Experts
Last 24hrsThis month
 Satya Prakash Swain 130 Richard MacCutchan 114 Atlapure Ambrish 95 OriginalGriff 95 Graeme_Grant 86
 OriginalGriff 4,963 RickZeeland 1,914 ppolymorphe 1,753 F-ES Sitecore 1,553 Dave Kreskowiak 1,379