<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Counting by ID in CDS view in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557033#M2007264</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;
  &lt;P&gt;I would like to count the records that are associated to the same ID.&lt;/P&gt;
  &lt;P&gt;For example:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;ID | DOCUMENT_NUMBER | COUNT 
1000       200             1 
1000       300             2 &lt;BR /&gt;2000       400             1 &lt;BR /&gt;3000       500             1 &lt;BR /&gt;3000       600             2&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;In SQL this was possible using the below statement.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;ROW_NUMBER( ) OVER( PARTITION BY ID ) AS COUNT&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;However, is this also possible using CDS views?&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Dhruv&lt;/P&gt;</description>
    <pubDate>Thu, 23 Dec 2021 16:43:08 GMT</pubDate>
    <dc:creator>former_member782701</dc:creator>
    <dc:date>2021-12-23T16:43:08Z</dc:date>
    <item>
      <title>Counting by ID in CDS view</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557033#M2007264</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
  &lt;P&gt;I would like to count the records that are associated to the same ID.&lt;/P&gt;
  &lt;P&gt;For example:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;ID | DOCUMENT_NUMBER | COUNT 
1000       200             1 
1000       300             2 &lt;BR /&gt;2000       400             1 &lt;BR /&gt;3000       500             1 &lt;BR /&gt;3000       600             2&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;In SQL this was possible using the below statement.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;ROW_NUMBER( ) OVER( PARTITION BY ID ) AS COUNT&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;However, is this also possible using CDS views?&lt;/P&gt;
  &lt;P&gt;Regards,&lt;/P&gt;
  &lt;P&gt;Dhruv&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 16:43:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557033#M2007264</guid>
      <dc:creator>former_member782701</dc:creator>
      <dc:date>2021-12-23T16:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by ID in CDS view</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557034#M2007265</link>
      <description>&lt;P&gt;Hello Dhruv,&lt;/P&gt;&lt;P&gt;I think it is not possible to use the ROW_NUMBER in the CDS. But this can be achieved either by using Table Function or create a virtual element in the CDS and fill the value.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Kumar C&lt;/P&gt;</description>
      <pubDate>Fri, 24 Dec 2021 03:55:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557034#M2007265</guid>
      <dc:creator>NaveenKumarC</dc:creator>
      <dc:date>2021-12-24T03:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by ID in CDS view</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557035#M2007266</link>
      <description>&lt;P&gt;It is not possible to use the ROW_NUMBER in the CDS.but altrnatively you can achieve through join &lt;/P&gt;&lt;P&gt;Left table: the original table you have&lt;/P&gt;&lt;P&gt;right table: using group by statement to get number of times id is repeated&lt;/P&gt;&lt;P&gt;perfom a left outer join to achieve the required output&lt;/P&gt;</description>
      <pubDate>Sat, 25 Dec 2021 06:57:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557035#M2007266</guid>
      <dc:creator>former_member688242</dc:creator>
      <dc:date>2021-12-25T06:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by ID in CDS view</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557036#M2007267</link>
      <description>&lt;P&gt;In my case I generate the original table using the following snippet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;define view entity &amp;lt;view_name&amp;gt;
as select from &amp;lt;view_1&amp;gt;
inner join   &amp;lt;view_2&amp;gt; on  &amp;lt;view_2&amp;gt;.field= &amp;lt;view_1&amp;gt;.field {

...

}
group by
...&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above view would provide the following output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;ID | DOCUMENT_NUMBER
1000       200
1000       300&lt;BR /&gt;2000       400&lt;BR /&gt;3000       500&lt;BR /&gt;3000       600&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now, I am not sure how to integrate a left outer join into that scenario. My left table would be the above view. However, what would be the right table?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 10:03:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557036#M2007267</guid>
      <dc:creator>former_member782701</dc:creator>
      <dc:date>2021-12-27T10:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Counting by ID in CDS view</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557037#M2007268</link>
      <description>&lt;P&gt;can you please try consume one cds view in another and link from sap: &lt;A href="https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_joined_data_source.htm"&gt;link&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 10:50:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/counting-by-id-in-cds-view/m-p/12557037#M2007268</guid>
      <dc:creator>former_member688242</dc:creator>
      <dc:date>2021-12-29T10:50:25Z</dc:date>
    </item>
  </channel>
</rss>

