on 05-12-2022 8:26 PM
Hi מיכל דוד,
If you are running MS SQL Server 2012 or higher, you can use the LAG function. For example:
select ItemCode AS [The ItemCode on this row]
,lag(ItemCode, 1, 'There is no previous row') over (order by ItemCode) AS [The ItemCode on the previous row]
from OITM<br>
or
SELECT x.[curr] AS [ItemCode]
,CASE
WHEN x.[curr] = x.[prev] THEN 1
ELSE 0
END AS [1 = same, 0 = different]
FROM (select ItemCode as [curr]
,lag(ItemCode, 1, 'There is no previous row') over (order by ItemCode) as [prev]
from QUT1) x
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you want to do it in Excel you can use the formula as in example below:
Make a new column as Number of Occurrence and then in the first row of the value field, amend the Formula as per your Column and row number. This will list the number of occurrence of each number in the column list.
Kr,
Jitin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can use Case with Count - on this link is an example https://stackoverflow.com/questions/17975229/using-sql-count-in-a-case-statement
I hope that helps,
Jesper
SELECT T0.[Docnum], ROW_NUMBER() OVER(PARTITION BY T0.DocNum ORDER BY T0.DocNum Asc) as NVeces
FROM ORDR T0 order by t0.DocNum
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.