I have two columns the first one I want top 10 products (1-10)
That is
SELECT TOP 10 * FROM Product
In the second column I want the next 10 results (11-20)
How do I do that?
It will return the top number of rows in the result set based on top_value. For example, TOP(10) would return the top 10 rows from the full result set. Optional.
select <column list you want> from <your table name> order by ProductName offset 100 rows fetch next 100 rows only; That will skip the first 100 rows (in order by ProductName) and return the next 100 rows.
WITH T AS ( SELECT TOP 20 name, row_number() OVER (ORDER BY id) AS RN FROM Products ORDER BY id ) SELECT MAX(CASE WHEN RN <=10 THEN name END) AS Col1, MAX(CASE WHEN RN > 10 THEN name END) AS Col2 FROM T GROUP BY RN % 10
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