|
SELECT d.股票代码, d.z, d.zx, n.净流入之总计, n.[5万以下之总计], n.[5-20万之总计], n.[20-50万之总计], (n.[50万以上之总计]-n.[100万以上之总计]) AS 50万以上, (n.[100万以上之总计]-n.[500万以上之总计]) AS 100万以上, (n.[500万以上之总计]-n.[800万以上之总计]) AS 500万以上, n.[800万以上之总计]
FROM (SELECT a.股票代码, a.z, (a.z-b.x) as zx FROM (SELECT 股票代码, 收盘价 AS z FROM sb WHERE 日期=date()) AS a INNER JOIN (SELECT 股票代码, min(收盘价) AS x FROM sb GROUP BY 股票代码) AS b ON a.股票代码=b.股票代码) AS d INNER JOIN (SELECT m.s.股票代码, Sum(nz(m.[5万以下],0)) AS 5万以下之总计, Sum(nz(m.[5-20万],0)) AS [5-20万之总计], Sum(nz(m.[20-50万],0)) AS [20-50万之总计], Sum(nz(m.[50万以上],0)) AS 50万以上之总计, Sum(nz(m.[100万以上],0)) AS 100万以上之总计, Sum(nz(m.[500万以上],0)) AS 500万以上之总计, Sum(nz(m.[800万以上],0)) AS 800万以上之总计, Sum(m.净流入) AS 净流入之总计
FROM (SELECT * FROM (SELECT * FROM sb AS s INNER JOIN (SELECT q.股票代码, min(q.日期) AS v FROM (SELECT o.股票代码, p.日期 FROM (SELECT 股票代码, min(收盘价) AS t FROM sb GROUP BY 股票代码) AS o INNER JOIN (SELECT 股票代码, 收盘价 AS u, 日期 FROM sb) AS p ON (o.股票代码=p.股票代码) AND (o.t=p.u)) AS q GROUP BY q.股票代码) AS r ON (s.股票代码=r.股票代码) AND (s.日期>=r.v)) AS [%$##@_Alias]) AS m
GROUP BY m.s.股票代码) AS n ON d.股票代码=n.股票代码;
你看看是否对 |
|