CREATE TABLE TEST (
customername varchar(50)
);
INSERT INTO TEST VALUES('CUSTOMER 1');
INSERT INTO TEST VALUES('CUSTOMER 1');
INSERT INTO TEST VALUES('CUSTOMER 1');
INSERT INTO TEST VALUES('CUSTOMER 2');
INSERT INTO TEST VALUES('CUSTOMER 2');
INSERT INTO TEST VALUES('CUSTOMER 2');
SELECT * FROM TEST ORDER BY ???
What ORDER BY clause should I put to get the following result ?:
"CUSTOMER 1"
"CUSTOMER 2"
"CUSTOMER 1"
"CUSTOMER 2"
"CUSTOMER 1"
"CUSTOMER 2"
SELECT customername
FROM TEST
ORDER BY ROW_NUMBER() OVER ( PARTITION BY customername ORDER BY customername )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With