i am making a select in which i want to bring all the rows for the last date that a certain user types in mesage - can be 0,1, or 10 eventhe thing is that ii make a select with an inner join of a table on itself to get the max(date) ===lastdate but withoguth dependency f the hours only the date!i use this code to ocnvert to a date structure of type dd/mm/yyyyCAST(FLOOR(CAST(@pInputDate AS DECIMAL(12, 5))) AS DATETIME)
and this is the quesy itselfSELECT COUNT(tblUsersMesag.client_id) AS countStatus, tblUsersMesag.client_id, tblUsersMesag.CompanyID, tblUsersMesag.CreateDateFROM tblUsersMesag INNER JOIN (SELECT client_id, CompanyID, MAX(CAST(FLOOR(CAST(tblUsersMesag.CreateDate AS DECIMAL(12, 5))) AS DATETIME)) AS maxcreatedate FROM tblUsersMesag GROUP BY client_id, CompanyID) lwcs1 ON tblUsersMesag.CompanyID = lwcs1.CompanyID AND tblUsersMesag.client_id = lwcs1.client_id AND tblUsersMesag.MAX(CAST(FLOOR(CAST(tblUsersMesag.CreateDate AS DECIMAL(12, 5))) AS DATETIME)) = lwcs1.maxcreatedateWHERE (tblUsersMesag.CompanyID = '511192601') AND (tblUsersMesag.client_id = '19559')GROUP BY tblUsersMesag.client_id, tblUsersMesag.CompanyID, tblUsersMesag.CreateDate
the problem is in the inner join in the "ON" part where id o tblUsersMesag.MAX(CAST(FLOOR(CAST(tblUsersMesag.CreateDate AS DECIMAL(12, 5))) AS DATETIME))
that is not acceptable!how can i sove thisthnaks inadvamncepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)