less shitty wrholder queries

This commit is contained in:
rtldg 2021-08-31 19:58:21 +00:00
parent c25e3404b4
commit 8bc2662418

View File

@ -1015,43 +1015,31 @@ public void SQL_Version_Callback(Database db, DBResultSet results, const char[]
"CREATE OR REPLACE VIEW %s%s AS \ "CREATE OR REPLACE VIEW %s%s AS \
SELECT \ SELECT \
0 as wrrank, \ 0 as wrrank, \
style, auth, wrcount \ style, auth, COUNT(auth) as wrcount \
FROM ( \ FROM %swrs WHERE track %c 0 GROUP BY style, auth;";
SELECT style, auth, SUM(c) as wrcount FROM ( \
SELECT style, auth, COUNT(auth) as c FROM %swrs WHERE track %c 0 GROUP BY style, auth \
) a GROUP BY style, auth \
) x;";
char sWRHolderRankTrackQueryRANK[] = char sWRHolderRankTrackQueryRANK[] =
"CREATE OR REPLACE VIEW %s%s AS \ "CREATE OR REPLACE VIEW %s%s AS \
SELECT \ SELECT \
RANK() OVER(PARTITION BY style ORDER BY wrcount DESC, auth ASC) \ RANK() OVER(PARTITION BY style ORDER BY wrcount DESC, auth ASC) \
as wrrank, \ as wrrank, \
style, auth, wrcount \ style, auth, COUNT(auth) as wrcount \
FROM ( \ FROM %swrs WHERE track %c 0 GROUP BY style, auth;";
SELECT style, auth, SUM(c) as wrcount FROM ( \
SELECT style, auth, COUNT(auth) as c FROM %swrs WHERE track %c 0 GROUP BY style, auth \
) a GROUP BY style, auth \
) x;";
char sWRHolderRankOtherQueryYuck[] = char sWRHolderRankOtherQueryYuck[] =
"CREATE OR REPLACE VIEW %s%s AS \ "CREATE OR REPLACE VIEW %s%s AS \
SELECT \ SELECT \
0 as wrrank, \ 0 as wrrank, \
-1 as style, auth, wrcount \ -1 as style, auth, COUNT(*) \
FROM ( \ FROM %swrs %s %s %s %s GROUP BY auth;";
SELECT COUNT(*) as wrcount, auth FROM %swrs %s %s %s %s GROUP BY auth \
) x;";
char sWRHolderRankOtherQueryRANK[] = char sWRHolderRankOtherQueryRANK[] =
"CREATE OR REPLACE VIEW %s%s AS \ "CREATE OR REPLACE VIEW %s%s AS \
SELECT \ SELECT \
RANK() OVER(ORDER BY wrcount DESC, auth ASC) \ RANK() OVER(ORDER BY wrcount DESC, auth ASC) \
as wrrank, \ as wrrank, \
-1 as style, auth, wrcount \ -1 as style, auth, COUNT(*) as wrcount \
FROM ( \ FROM %swrs %s %s %s %s GROUP BY auth;";
SELECT COUNT(*) as wrcount, auth FROM %swrs %s %s %s %s GROUP BY auth \
) x;";
char sQuery[800]; char sQuery[800];
Transaction hTransaction = new Transaction(); Transaction hTransaction = new Transaction();