Skip to content
Loading
  • Kanimozhi Shivakumar
    0
    I tried with LAG function. But i am getting below error..I am using MS SQL server 2012
     
    0
  • Jeeva Subburaj
    0
    Lag was introduced in sql 2012.. Are you sure you are using SQL server 2012?
    0
  • Kanimozhi Shivakumar
    0
    Sure . I am using MS SQL server 2012 only.
     
    0
  • Kanimozhi Shivakumar
    0
     
    I have MS SQL Server 2012 installed in my system.. But I am using server DB.I checked the version it is showing as 2008 as shown in above fig.
    0
  • Jeeva Subburaj
    0
    can you run this query and post the answer.. SELECT @@VERSION
    0
  • Kanimozhi Shivakumar
    0
    Is there any alternate solution for LAG function in  MS SQL Server 2008 version?
    0
  • Jeeva Subburaj
    0
    you can do that in SQL 2008 with self join but it may look little complex query. Look at this link for your reference and modify your query accordingly.
     
    https://blog.sqlauthority.com/2011/11/24/sql-server-solution-to-puzzle-simulate-lead-and-lag-without-using-sql-server-2012-analytic-function/ 
    0
  • Jefferson S. Motta
    0
     I understand the data, but not the procedure to organize data.
    Couldn't you create a temp table and fill as you wish?
    good luck,
    Jeff
    0
  • Jignesh Kumar
    0
    Hi Kanimozhi,
     
    Please find this article it will help you. you can use LAG() function to solve your issue.
     
    https://www.codeproject.com/Tips/1138678/How-to-Format-Repeating-Values-in-SQL-Result-Set
    0
  • Kanimozhi Shivakumar
    0
    Hi Jignesh Kumar,
     
    Please read previous conversation..
     
    Jeevanatham Subburaj already explained about LAG function and that is not applicable for SQL 2008 version.
     
    I think I have one option what suggested by Jefferson S. Motta
     
    Thank you all for your replies
    0
  • 0
    private void dataGridView1_CurrentCellChanged(object sender, EventArgs e) Use this event It may help you Write query in this event Thank you
    0
  • Kanimozhi Shivakumar
    0
    Hi Ruchi
     
    I made few changes on your query...Now it is working perfectly the way I want it..
     
    Thank you so much .. 
    0