Hi robert,
Is there any reason you don't want to use sum() and group by ?? This is exactly how I would solve it.
SELECT month, SUM(pen) as pen, SUM(pencil) as pencil, SUM(book) as Book ;
FROM MyTable ;
GROUP BY Month
There are of course other ways to do it, but I'd like to hear your motivation to reject the solution above ?
Walter,
>Dear Experts
>
>I have table1, containing data as follows
>
>month pen pencil book
>jan 15 20 35
>feb 27
>feb 37 16
>mar 5 7 98
>apr 47
>apr 46
>apr 45
>
>
>In table1, month feb and apr comes more than one times. If a month comes more than one times then data of other records of the same month should come in first occourance in related fields. I do not want to use command like select sum(pen). The result should look this
>
>month pen pencil book
>jan 15 20 35
>feb 37 27 16
>mar 5 7 98
>apr 45 46 47
>
>Please help