Quantcast
Channel: T-SQL question
Browsing index pages (5 articles)
↧

T-SQL question

Hello All,I have a table called TOTAL_DEPTH and here is the script for itCREATE TABLE #TOTAL_DEPTH( well_id int,Report_dt date, source_id int,totl_dpth int, tvd_dpth int) INSERT INTO #TOTAL_DEPTH...

View Article


Image may be NSFW.
Clik here to view.

T-SQL question

CREATE TABLE #TOTAL_DEPTH( well_id int,Report_dt date, source_id int,totl_dpth int, tvd_dpth int) INSERT INTO #TOTAL_DEPTH VALUES (11, '9/25/2017',16,0, 0) INSERT INTO #TOTAL_DEPTH VALUES...

View Article


T-SQL question

Hi Srik Kotte,You can use LAG function in a CTE like below to achieve this:;WITH CTE_TD AS ( SELECT * ,LAG(totl_dpth,1,0) OVER(PARTITION BY well_id ORDER BY Report_dt) PrevTotl_dpth ,LAG(tvd_dpth,1,0)...

View Article

T-SQL question

Hi Srik,What is your SQL Server version? Since LAG() function is only used after SQL Server 2012. So if you are using the prior version. You can try following script:CREATE TABLE #TOTAL_DEPTH( well_id...

View Article

T-SQL question

Thank you all. All of the above solutions worked for me.Thank you so much once again.

View Article

Browsing index pages (5 articles)


Latest Images