HI All
I have a table that contains all the transactions on our stock
I need to extract the transactions with an entry type of I or C for a date period
I then need to add all the quantities for each stock Item sold to individual customers
eg
07/06/2007 I @OF001 7704190 2
04/07/2007 I @OF001 7704190 2
07/09/2007 I @OF001 7704190 1
15/10/2007 C @OF001 7704190 -1
01/02/2008 I @OF001 7704190 1
06/03/2008 I @OF001 7704190 1
15/02/2008 I @OF001 4400396SA 1
18/02/2008 I @OF001 4400434SA 1
05/03/2008 I @OF001 4400434SA 1
25/02/2008 I AMY001 4400424 2
13/02/2008 I AMY001 4400396SA 2
08/02/2008 I AMY001 4400434SA 1
My Result should be
@OF001 7704190 6
@OF001 4400396SA 1
@OF001 4400434SA 2
AMY001 4400424 2
AMY001 4400396SA 2
AMY001 4400434SA 1
I have the following Query
$sql_strans = SELECT
DATE,
ENTRY,
ACCNO,
STOCKNO,
QTY,
FROM
sttrans
WHERE
DATE >= '2007-01-07' AND
DATE <= '2008-03-31' AND
ENTRY = 'C' OR
ENTRY = 'I'
GROUP BY
STOCKNO
ORDER BY
ACCNO ASC
There seems to be a problem with the "Where entry" and the I need to get it to add together.
What Have I done Wrong
Thanks
Martin