Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save codejake/0cb3b74e57a72b9fa00c86e4f0e07cda to your computer and use it in GitHub Desktop.
Save codejake/0cb3b74e57a72b9fa00c86e4f0e07cda to your computer and use it in GitHub Desktop.
select a.* from (
select
[id],
[User_Name],
[Client_IP_Address],
[Called_Station_Id],
[Packet_Type],
[Reason-Code],
LAG([Calling_Station_ID],1) OVER( PARTITION BY [User_Name] ORDER BY [User_Name]) client FROM [NPSODBC].[dbo].[accounting_data] WHERE [Reason-Code] != 0
) a
ORDER BY [id] DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment