Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on docs #2005

Open
ConradWen opened this issue Feb 8, 2025 · 2 comments
Open

Issue on docs #2005

ConradWen opened this issue Feb 8, 2025 · 2 comments

Comments

@ConradWen
Copy link

CREATE TABLE test_percent_rank (
productLine VARCHAR,
orderYear INT,
orderValue DOUBLE,
percentile_rank DOUBLE
) ENGINE=OLAP
DISTRIBUTED BY HASH(orderYear) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);

productLine VARCHAR does not specify length,such as VARCHAR (100).

@ConradWen
Copy link
Author

Path:/zh-CN/docs/sql-manual/sql-functions/window-functions/percent-rank
The test data can be used as the following examples:

create table test_percent_rank
(
productLine varchar(128),
orderYear int,
orderValue double,
percentile_rank double
)
engine=olap
distributed by hash(orderYear) buckets 4
properties(
"replication_num"="1"
);

INSERT INTO test_percent_rank (productLine, orderYear, orderValue, percentile_rank)
VALUES
('Motorcycles', 2003, 2440.50, 0.00),
('Trains', 2003, 2770.95, 0.17),
('Trucks and Buses', 2003, 3284.28, 0.33),
('Vintage Cars', 2003, 4080.00, 0.50),
('Planes', 2003, 4825.44, 0.67),
('Ships', 2003, 5072.71, 0.83),
('Classic Cars', 2003, 5571.80, 1.00),
('Motorcycles', 2004, 2598.77, 0.00),
('Vintage Cars', 2004, 2819.28, 0.17),
('Planes', 2004, 2857.35, 0.33),
('Ships', 2004, 4301.15, 0.50),
('Trucks and Buses', 2004, 4615.64, 0.67),
('Trains', 2004, 4646.88, 0.83),
('Classic Cars', 2004, 8124.98, 1.00),
('Ships', 2005, 1603.20, 0.00),
('Motorcycles', 2005, 3774.00, 0.17),
('Planes', 2005, 4018.00, 0.50),
('Vintage Cars', 2005, 5346.50, 0.67),
('Classic Cars', 2005, 5971.35, 0.83),
('Trucks and Buses', 2005, 6295.03, 1.00);

select * from test_percent_rank;

select
productLine,
orderYear,
orderValue,
round(percent_rank() over (partition by orderYear
order by orderValue),2) as percentile_rank
from test_percent_rank
order by orderYear;

@KassieZ
Copy link
Contributor

KassieZ commented Feb 21, 2025

Thank you for the feedback, will fix it ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants