KFurstenberg
Programmer
I have a situation, using UDB, in which I am attempting to return only the top 15. I'm getting all the rows since the COUNT is always a value of 1 (HAVING clause isn't making any difference). This is how the SQL was originally written in order to accomplish this:
' DB2
Set conn = Server.CreateObject("ADODB.Connection"
conn.Open "DSN=DFOC01;UID=********;PWD=********"
SQLStmt0 = "SELECT FOCP.TFOC_BATCH_CONTROL.VALUATION_DATE AS VALUATION_DATE, "
SQLStmt0 = SQLStmt0 + " YEAR(FOCP.TFOC_BATCH_CONTROL.VALUATION_DATE) AS YEAR, "
SQLStmt0 = SQLStmt0 + " MONTH(FOCP.TFOC_BATCH_CONTROL.VALUATION_DATE) AS MONTH, "
SQLStmt0 = SQLStmt0 + " DAY(FOCP.TFOC_BATCH_CONTROL.VALUATION_DATE) AS DAY "
SQLStmt0 = SQLStmt0 + " FROM FOCP.TFOC_BATCH_CONTROL "
SQLStmt0 = SQLStmt0 + " GROUP BY VALUATION_DATE HAVING COUNT(*) < 16"
SQLStmt0 = SQLStmt0 + " ORDER BY 1 DESC"
Set rs0 = conn.Execute(SQLStmt0)
Any suggestions as to how I can retrieve just the top 15? This is being executed within an ASP. The primary key in the table is VALUATION_DATE. TIA.