I have a table with a list of folders that looks like this:
Path Size
C:\ParentFolder\A 123
C:\ParentFolder\A\B 442434
C:\ParentFolder\A\B\C 13413412
C:\ParentFolder\D 2422341234
C:\ParentFolder\D\E 3342
C:\ParentFolder\D\E\F 2
C:\ParentFolder\D\E\G 2
...
I'm looking for some combination of SUM, GROUP BY, and PATINDEX/LTRIM/SUBSTRING/etc. which would give me back this:
Path SumSize
C:\ParentFolder\A 13855969
C:\ParentFolder\D 2422344580
...
C:\ParentFolder is a known prefix, but A,D,etc. are variable folder names. Do I need to write a function to accomplish that or can I use some combination of string functions?