HolgerWang1999 commented on issue #35844:
URL: https://github.com/apache/doris/issues/35844#issuecomment-2149068147
复现SQL示例:
```sql
CREATE TABLE digital_marketing.substring_test (
`id` INT COMMENT 'id',
`k1` STRING,
`k2` DATE
)
UNIQUE KEY (id)
DISTRIBUTED BY HASH(id) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default:2",
"enable_unique_key_merge_on_write" = "true"
);
INSERT
OVERWRITE TABLE digital_marketing.substring_test
VALUES
(1, 'EDM:mailId:123456789', '2024-01-01'),
(2, 'EDM:mailId:123456789', '2024-01-02');
SELECT
*
FROM
(
SELECT
mail_id
FROM
(
SELECT
SUBSTRING(k1, 12) AS mail_id,
RANK() OVER (
PARTITION BY
k1
ORDER BY
k2 DESC
) AS rk
FROM
digital_marketing.substring_test
) tmp
WHERE
rk = 1
) a
JOIN (
SELECT
mail_id
FROM
(
SELECT
SUBSTRING(k1, 12) AS mail_id,
RANK() OVER (
PARTITION BY
k1
ORDER BY
k2 DESC
) AS rk
FROM
digital_marketing.substring_test
) tmp
WHERE
rk = 1
) b ON a.mail_id = b.mail_id;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]