
Originally Posted by
venkat6134
creditdate( like 01-mar-11)
this looks like a VARCHAR column
since you didn't mention which database you're using, i'm going to assume it's mysql, and i'm also going to assume that creditdate is an actual DATE column, and not a VARCHAR
Code:
SELECT DATE_FORMAT(creditdate,'%b-%Y') AS mthyyyy
, SUM(total1) AS sum_total1
, SUM(total2) AS sum_total2
, SUM(total3) AS sum_total3
FROM tab1
INNER
JOIN tab2
ON tab2.itemno = tab1.itemno
WHERE tab1.distcode IN ( 'A','B' )
GROUP
BY mthyyyy
if either of my assumptions is not true, you will ahve to change the first line of the SELECT
Bookmarks