I have the following query generated in a Cognos report.
My problem is I need it to work, with the same logic / filter in SQL Server. Can the filter below (COGNOS syntax) be generated to work in the same way, like a WHERE
in SQL Server?
select
*
from
dbo.ia_code
group by
client__iacode.ia_code,
client__iacode.ia_short_descr
------ here my problem
filter
(rank() over ( at client__iacode.ia_code order by XCOUNT(client.client_code at client__iacode.ia_code,client.client_id for client__iacode.ia_code ) desc nulls last) <= 25) and
(RCOUNT(rank() over ( at client__iacode.ia_code order by XCOUNT(client_document.client_document_id for client__iacode.ia_code ) desc nulls last) at client__iacode.ia_code order by rank() over ( at client__iacode.ia_code order by XCOUNT(client_document.client_document_id for client__iacode.ia_code ) desc nulls last) asc,client__iacode.ia_code asc,client__iacode.ia_short_descr asc ) <= 25)
Any help would be appreciated.
where
before group by for filterselect
Sum(id),client__iacode.ia_code,client__iacode.ia_short_descr
from
dbo.ia_code
group by
client__iacode.ia_code,
client__iacode.ia_short_descr
Read this statement for how to use:
in finally: I tried change your code to sql server but i don't now about out put of this code. please add table sample data and sample of out put.
First try changing the query's (or data source's) "Rollup Processing" property to "Database". That should help converting extended aggregate functions (XCOUNT etc) to native SQL. Also check out "Use SQL parameters" property and set it to "Literal" and see if that will helps with the parameters in native SQL. Once you do those, paste the new generated native query here.
Screenshot of the properties window
This is a snippet from my answer to the following Stackoverflow question. Read more details there and also follow that question as it may help with your question too.
Convert IBM Cognos SQL which contains a filter to Microsoft SQL Server Query
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.