cols="trackId,trackName,averageUserRating,userRatingCount,averageUserRatingForCurrentVersion,userRatingCountForCurrentVersion"
cols="trackId,trackName,averageUserRating,userRatingCount,averageUserRatingForCurrentVersion,userRatingCountForCurrentVersion"
-- Spanish Application TOP
WITH raw_es as (
SELECT rowNumberInAllBlocks() + 1 as es_rank, * -- all columns from V_1001 + rank
FROM DS_.V_1001
),
-- Portugese Application TOP
raw_pt as (
SELECT rowNumberInAllBlocks() + 1 as pt_rank, * -- all columns from V_1001 + rank
FROM DS_.V_1002
)
-- Mix them together by their app_id and calculate the diff in rate
SELECT trackId as app_id,
trackName as appName,
es_rank,
pt_rank,
es_rank - pt_rank as rank_diff,
averageUserRating as es_rating,
raw_pt.averageUserRating as pt_rating,
es_rating - pt_rating as rating_diff
FROM raw_es
INNER JOIN raw_pt
ON raw_es.trackId = raw_pt.trackId