40 lines
776 B
MySQL
40 lines
776 B
MySQL
|
-- Clean up 0 file Counts
|
||
|
delete from FolderData
|
||
|
where FileCount = 0;
|
||
|
DROP table DuplicateList;
|
||
|
create TABLE DuplicateList AS
|
||
|
SELECT *
|
||
|
from FolderData AS A
|
||
|
where A.Project in (
|
||
|
select Project
|
||
|
from FolderData
|
||
|
group by Project
|
||
|
HAVING count(*) > 1
|
||
|
);
|
||
|
-- Generate Non-Duplicated PARENT FOLDER List
|
||
|
DROP table NonDupParent;
|
||
|
CREATE TABLE NonDupParent AS
|
||
|
SELECT SERVER,
|
||
|
Parent,
|
||
|
sum(FileCount),
|
||
|
Sum(FileSize)
|
||
|
from FolderData
|
||
|
Where Parent not in (
|
||
|
SELECT Parent
|
||
|
FROM DuplicateList
|
||
|
)
|
||
|
group by Parent
|
||
|
ORDER BY Server;
|
||
|
-- Generate Non-Duplicated PROJECT FOLDER List
|
||
|
DROP TABLE NonDupProject;
|
||
|
create table NonDupProject AS
|
||
|
select *
|
||
|
from FolderData
|
||
|
where Project not in (
|
||
|
Select Project
|
||
|
from DuplicateList
|
||
|
)
|
||
|
AND Parent not in (
|
||
|
Select Parent
|
||
|
from NonDupParent
|
||
|
);
|