日期:2014-05-17 浏览次数:21512 次
SELECT DISTINCT
A.*
FROM SecuCode A
JOIN "LC_Table" B ON B."CompanyCode" = A."CompanyCode"
AND B."EndDate" = (SELECT MAX("EndDate") FROM "LC_Table" WHERE "CompanyCode" = A."CompanyCode" AND "EndDate"<=v_date)
LEFT JOIN "LC_Table" C ON C."CompanyCode" = A."CompanyCode"
AND C."EndDate" = (SELECT MAX("EndDate") FROM "LC_Table" WHERE "CompanyCode" = A."CompanyCode" AND "EndDate"<B."EndDate")
WHERE A."SecuCategory" IN (1,2) AND A."SecuMarket" IN (83,90)
AND (B.SHNum*1.0/NULLIF(C.SHNum,0)-1)*100.0<-50
AND A."ListedDate"<=v_date
AND NOT EXISTS
(
SELECT "InnerCode"
FROM "LC_ListStatus" WHERE "InnerCode" = A."InnerCode" AND "SecuMarket" = A."SecuMarket"
AND "ChangeDate"<=v_date AND "ChangeType" IN (4,5,20)
AND rownum<=1
);