12,398,000 members (43,382 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.
Member 9799439 30-Apr-13 5:53am

Yep Sure.Next time i will improve my question.

Try removing ORRMCTG from ORDER BY.

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
 OriginalGriff 380 Richard Deeming 244 Richard MacCutchan 200 Karthik Bangalore 190 ppolymorphe 110
 OriginalGriff 6,508 Karthik Bangalore 2,572 ppolymorphe 2,540 F-ES Sitecore 1,977 Richard MacCutchan 1,952