All pastes #329346 Raw Edit

Unnamed

public text v1 · immutable
#329346 ·published 2007-01-26 18:04 UTC
rendered paste body
SELECT
	0 as orderkey,
	history.mtype as mtype,
	history.clientid as clientid,
	ClientInfo.Firstname as firstname,
	ClientInfo.LastName as lastname,
	history.amount as amount,
	history.description as description,
	history.datereceived as datereceived
FROM history JOIN ClientInfo
ON history.clientid = clientinfo.clientid
UNION
SELECT * FROM (SELECT
	1 as orderkey,
	null as mtype,
	null as clientid,
	null as firstname,
	null as lastname,
	SUM(history.amount) as amount,
	'total' as description,
	history.datereceived as datereceived
FROM history JOIN ClientInfo
ON history.clientid = clientinfo.clientid
GROUP BY history.datereceived)
ORDER BY daterecieved,orderkey

--lokkju