sql - Implementing a "distinct" select in an existing query -


I have an existing, long, SQL query. I want to select the records which is a separate mt.ID. I have tried to put "selection variants" in different places without any success. Can anyone tell me where he should go? thanks a lot. Select << p>

  SELECT * FROM (ROW_NUMBER () as roam, mt_id as mt.ID, mt.title as mt_title, [[ORDER "+ orderField + @"]). ..] st'title as st'title, [...] can be included in the mt internal as mt stt as mt.id = st.id sttable on where not (st.field = 0) and Where @ mr.title = @title ") DerivedTableName between WHERE RowNum (@ PageIndex - 1) * @ PageSize + 1) and @ Page Index * @ Page Size  

The problem is that many sttable records for each mttable record So you do not need DISTINCT but a GROUP BY .

I will try something like the following for internal selection:

  SELECT ROW_NUMBER () over (ORDER BY "+ OrderField + @") AS Ronam, MTID AS MTiID, MTTTL AS MT_CHITAL, [...] Max (STT) as SST_title, other For all columns - Other set (MAX, MIN, AVERAGE, ...) - From stabels, whichever is appropriate. MT.ID = st.ID WHERE st.field at ST as MT Inner Job Stabate as mttable from [...] & Gt; 0 and mt.title = @title Group by MTID, MT Titles - everything group from ametables.  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -