I have a directory listing in a table called DATA (with a file extension field called DATAEXT) which I want to count in another table called STATS.
In the STATS table, I've already populated an STATSEXT column using;
INSERT INTO STATS (STATSEXT) SELECT DISTINCT DATAEXT FROM DATA;
I now want to write a query that goes through all the individual extensions listed in the STATS table, and counts the number of files with that extension in DATA, putting the result into a column called FILECOUNT in STATS.
I know I can use:
SELECT DATAEXT,count(*) FROM DATA GROUP BY DATAEXT
but it doesn't put the results into STATS. Also, the solution needs to use the STATSEXT values in STATS as the basis of the lookup, rather than deriving it from the DATAEXT values, which is what the above does.
Any suggestions gratefully received. I've tried using a join based on a comparison of DATAEXT and STATSEXT, but it just counts the entire file listing (presumably as all the STATSEXT values are in the file listing somewhere).
Thank you.
Aucun commentaire:
Enregistrer un commentaire