I have a query that fetches system data about a database
$data = Query "SELECT [server_name]
,[sessionID]
,[user]
,[ElapsedTime]
from table"
$data | Export-Csv -Path $Path\data.csv -NoTypeInformation
Recently I've noticed there are duplicate entries for sessionID in the data exported. Is there an option to select distinct by session ID only?
Something like
Query "SELECT [server_name]
,SELECT DISTINCT[sessionID]
,SELECT [user]
,[ElapsedTime]
from table"
For example, if the table has:
The exported csv should only contain: