I have two queries.
select files.originalfilename from files inner join digitalfiles on files.fileid = digitalfiles.fileid where digitalfiles.path in ( select * from Staple )
This will get the orginialfilename with extensions. Like below:
Now the second query:
select ft.Extension ,COUNT(f.OriginalFileName) as [Count] ,sum(df.Length) / 1024 as [Size KB] ,ft.FileTypeId ,cast(count(f.OriginalFileName) * 100.0 / sum(count(*)) over () as decimal(18, 6)) as [Pct] from Files f inner join DigitalFiles df on f.FileId = df.FileId left join FileTypes ft on df.FileTypeId = ft.FileTypeId where f.Deleted = 1 group by ft.Extension ,ft.FileTypeId
This query will give me output as: Extension, Count, Size KB, File ID, Percentage
I want to use the result of first query in second query and get the result.