SELECT DISTINCT m.customer,
c.name,
c.customer,
(SELECT Top 1 fd.Fee1 FROM FSch fd
where c.FSch = fd.code)
AS FSch,
m.Branch,
CASE WHEN ph.bgg in ('U' ,'R', 'P',= 'D') Then
(-ph.tpaid + ph.oFee)
ELSE
(ph.tpaid - ph.oFee)
END AS [Amount],
DATENAME(m, '2006'+right('0'+convert(v
ph.systemyear
.....
Main Topics
Browse All Topics





by: rafranciscoPosted on 2006-05-22 at 13:19:57ID: 16737565
Looks like your systemmonth only contains the numeric month value and not a whole date value. If this is the case, you can do the following:
SELECT DISTINCT m.customer,
c.name,
c.customer,
(SELECT Top 1 fd.Fee1 FROM FSch fd
where c.FSch = fd.code)
AS FSch,
m.Branch,
CASE WHEN ph.bgg = 'U' OR ph.btype = 'R' OR ph.bgg = 'P' OR ph.bgg = 'D' Then
(-ph.tpaid + ph.oFee)
ELSE
(ph.tpaid - ph.oFee)
END AS [Amount],
DATENAME(m, CAST(CAST(ph.systemmonth AS VARCHAR(2)) + '/01/2006' AS DATETIME)) as systemmonth,
ph.systemyear