简体   繁体   English

将报告从 COGNOS 迁移到 SQL 服务器

[英]Migrate report from COGNOS to SQL Server

I have the following query generated in a Cognos report.我在 Cognos 报告中生成了以下查询。

My problem is I need it to work, with the same logic / filter in SQL Server.我的问题是我需要它在 SQL 服务器中使用相同的逻辑/过滤器来工作。 Can the filter below (COGNOS syntax) be generated to work in the same way, like a WHERE in SQL Server?是否可以生成下面的过滤器(COGNOS 语法)以相同的方式工作,例如 SQL 服务器中的WHERE

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.任何帮助,将不胜感激。

  1. Use where before group by for filter在 group by 之前使用where过滤器
  2. Group by just use for aggregate-function call in query like below分组仅用于查询中的聚合函数调用,如下所示
select
      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
  1. Use having for functionality filter in query在查询中使用具有功能过滤器

Read this statement for how to use:阅读此声明以了解如何使用:

  1. Where: w3schools地点: w3schools
  2. Group by: w3shoolcs分组方式: w3shoolcs
  3. Having: w3shoolcs拥有: w3shoolcs

in finally: I tried change your code to sql server but i don't now about out put of this code.最后:我尝试将您的代码更改为 sql 服务器,但我现在不打算删除此代码。 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.这应该有助于将扩展聚合函数(XCOUNT 等)转换为原生 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.另请查看“使用 SQL 参数”属性并将其设置为“文字”,看看这是否有助于本机 SQL 中的参数。 Once you do those, paste the new generated native query here.完成这些操作后,将新生成的本机查询粘贴到此处。

Screenshot of the properties window属性 window 的屏幕截图

This is a snippet from my answer to the following Stackoverflow question.这是我对以下 Stackoverflow 问题的回答中的一个片段。 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 将包含过滤器的 IBM Cognos SQL 转换为 Microsoft SQL 服务器查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM