<commit_before>CREATE TABLE sampleData ( groupID int, numValue int );
INSERT INTO sampleData VALUES ( 1,   1 );
INSERT INTO sampleData VALUES ( 1,   2 );
INSERT INTO sampleData VALUES ( 1,   6 );
INSERT INTO sampleData VALUES ( 1,  16 );
INSERT INTO sampleData VALUES ( 1,   7 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,  11 );
INSERT INTO sampleData VALUES ( 3,  10 );
INSERT INTO sampleData VALUES ( 3,  17 );
INSERT INTO sampleData VALUES ( 3,  52 );
INSERT INTO sampleData VALUES ( 3,  66 );
INSERT INTO sampleData VALUES ( 4,  18 );
INSERT INTO sampleData VALUES ( 5,   0 );
INSERT INTO sampleData VALUES ( 5,   0 );
INSERT INTO sampleData VALUES ( 5,   0 );

SELECT count(*) from sampleData;

-- Median tests
SELECT median(numValue) FROM sampleData;  -- should return 6.5 (or 6, or 7)
SELECT median(groupID) FROM sampleData;  -- should return 2
SELECT groupID, median(numValue) FROM sampleData ORDER BY groupID;  -- should return (4, 5, 34.5, 18,  0)


SELECT R.groupID, AVG(1.0*R.numValue) AS medianValue
FROM
(    SELECT GroupID, numValue, ROW_NUMBER() OVER(PARTITION BY groupID ORDER BY NumValue) AS rowno
    FROM sampleData
) R
INNER JOIN<commit_msg>Typo in query<commit_after>CREATE TABLE sampleData ( groupID int, numValue int );
INSERT INTO sampleData VALUES ( 1,   1 );
INSERT INTO sampleData VALUES ( 1,   2 );
INSERT INTO sampleData VALUES ( 1,   6 );
INSERT INTO sampleData VALUES ( 1,  16 );
INSERT INTO sampleData VALUES ( 1,   7 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,   5 );
INSERT INTO sampleData VALUES ( 2,  11 );
INSERT INTO sampleData VALUES ( 3,  10 );
INSERT INTO sampleData VALUES ( 3,  17 );
INSERT INTO sampleData VALUES ( 3,  52 );
INSERT INTO sampleData VALUES ( 3,  66 );
INSERT INTO sampleData VALUES ( 4,  18 );
INSERT INTO sampleData VALUES ( 5,   0 );
INSERT INTO sampleData VALUES ( 5,   0 );
INSERT INTO sampleData VALUES ( 5,   0 );

SELECT count(*) from sampleData;

-- Median tests
SELECT median(numValue) FROM sampleData;  -- should return 6.5 (or 6, or 7)
SELECT median(groupID) FROM sampleData;  -- should return 2
SELECT groupID, median(numValue) FROM sampleData GROUP BY groupID;  -- should return (6, 5, 34.5, 18,  0)


SELECT R.groupID, AVG(1.0*R.numValue) AS medianValue
FROM
(    SELECT GroupID, numValue, ROW_NUMBER() OVER(PARTITION BY groupID ORDER BY NumValue) AS rowno
    FROM sampleData
) R
INNER JOIN
{'fraction_non_alphanumeric': 0.09601873536299765, 'fraction_numerical': 0.04371584699453552, 'mean_word_length': 3.7728119180633146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1340946', 'n_tokens_mistral': 921, 'n_tokens_neox': 773, 'n_words': 343}