Click to view latest messages in all forums
| | | | This topic has been archived, and won't accept reply postings. |
Topic - SQL Puzzler
|
|---|
by - mostly harmless on - 30 Nov 2012 |
A slight variation here, in that the code works but I don't understand why. Can anyone tell me what the "any_string_here" does after the brackets where the table is partitioned. It works with any characters but I don't understand why.
Thanks in adavance
Dave
-------------------------------------------------------
DECLARE @TABLE TABLE (A INT, B INT,C VARCHAR(6))
INSERT INTO @TABLE VALUES
(1,123,'abc'),(1,122,'abc'),
(1,121,'abc'),(2,23,'z'),
(2,23,'efg'),(2,23,'ahij')
SELECT * FROM @TABLE
SELECT
A,B,C,ROWNUM FROM(
SELECT A,B,C,ROW_NUMBER() OVER(PARTITION BY A ORDER BY B DESC) ROWNUM
FROM @TABLE
) any_string_here
WHERE ROWNUM = 1 |
... not showing 5 replies to this topic ...
Register as a New User or login to gain full access to the forums. Registration is quick and completely free.
If you are definitely logged on, press Ctrl+F5 keys to reload this page [read more]

Unregistered users can only read messages in the most recent topics. |
 |
| | | | This topic has been archived, and won't accept reply postings. |
[top of page] - [forums latest]
|