locked
Particular row value in table RRS feed

  • Question

  •   I have table with 10 rows.I need to take particular row value.

    ex-5 th row for a particular column


    • Edited by sri_1980 Friday, January 20, 2012 7:16 AM
    Friday, January 20, 2012 7:15 AM

Answers

  • Hi Sri,

    Try this: If we have a table SalesOrderHeader 5th row can be found be this way.

    WITH OrderedOrders AS
    (
        SELECT SalesOrderID, OrderDate,
        ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber'
        FROM Sales.SalesOrderHeader 
    ) 
    SELECT * 
    FROM OrderedOrders 
    WHERE RowNumber=5;
    
    Reference

     

    Thanks!


    Every day its a new learning. Keep Learning!!
    If this post answers your question, please click Mark As Answer . If this post is helpful please click Mark as Helpful
    • Marked as answer by Lola Wang Monday, January 23, 2012 5:52 AM
    Friday, January 20, 2012 8:58 AM

All replies

  • Hi,

    Not sure, I understood your requirement clearly but see if this expression helps you.

    =IIF(ROWNUMBER(NOTHING) = 5, <Your required value>, NOTHING)
    



    Regards,

    Asim Bagwan

    Kindly mark the replies as Answers if they help!

    Friday, January 20, 2012 7:39 AM
  • Hi Sri,

    Try this: If we have a table SalesOrderHeader 5th row can be found be this way.

    WITH OrderedOrders AS
    (
        SELECT SalesOrderID, OrderDate,
        ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber'
        FROM Sales.SalesOrderHeader 
    ) 
    SELECT * 
    FROM OrderedOrders 
    WHERE RowNumber=5;
    
    Reference

     

    Thanks!


    Every day its a new learning. Keep Learning!!
    If this post answers your question, please click Mark As Answer . If this post is helpful please click Mark as Helpful
    • Marked as answer by Lola Wang Monday, January 23, 2012 5:52 AM
    Friday, January 20, 2012 8:58 AM