Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 118905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:34:07+00:00 2026-05-11T03:34:07+00:00

I have a set of records in my MS SQL table. With Date as

  • 0

I have a set of records in my MS SQL table. With Date as the primary key. But the Dates are only for working days and not the continues days. Eg:

1/3/2000 12:00:00 AM 5209.540000000 5384.660000000 5209.540000000 5375.110000000 1/4/2000 12:00:00 AM 5533.980000000 5533.980000000 5376.430000000 5491.010000000 1/5/2000 12:00:00 AM 5265.090000000 5464.350000000 5184.480000000 5357.000000000 1/6/2000 12:00:00 AM 5424.210000000 5489.860000000 5391.330000000 5421.530000000 1/7/2000 12:00:00 AM 5358.280000000 5463.250000000 5330.580000000 5414.480000000 1/10/2000 12:00:00 AM 5617.590000000 5668.280000000 5459.970000000 5518.390000000 1/11/2000 12:00:00 AM 5513.040000000 5537.690000000 5221.280000000 5296.300000000 1/12/2000 12:00:00 AM 5267.850000000 5494.300000000 5267.850000000 5491.200000000

In this i am trying to introduce a new column to the table and the value to it should be the value of the 3rd cloumn minus the value of 3rd column of the previous working day. Please help me in writing such a query. I am finding it difficult as the dates are not present for the week ends.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:34:07+00:00Added an answer on May 11, 2026 at 3:34 am

    There are a few ways of doing this. Here is one.

    CREATE TABLE MyTable (     MyDate datetime NOT NULL PRIMARY KEY,     Col2 decimal(14,4) NOT NULL,     Col3 decimal(14,4) NOT NULL,     Col4 decimal(14,4) NOT NULL,     Col5 decimal(14,4) NOT NULL ) GO  INSERT INTO MyTable SELECT '1/3/2000 12:00:00 AM', 5209.540000000, 5384.660000000, 5209.540000000, 5375.110000000   UNION ALL  SELECT '1/4/2000 12:00:00 AM', 5533.980000000, 5533.980000000, 5376.430000000, 5491.010000000  UNION ALL  SELECT '1/5/2000 12:00:00 AM', 5265.090000000, 5464.350000000, 5184.480000000, 5357.000000000  UNION ALL  SELECT '1/6/2000 12:00:00 AM', 5424.210000000, 5489.860000000, 5391.330000000, 5421.530000000   UNION ALL  SELECT '1/7/2000 12:00:00 AM', 5358.280000000, 5463.250000000, 5330.580000000, 5414.480000000   UNION ALL  SELECT '1/10/2000 12:00:00 AM', 5617.590000000, 5668.280000000, 5459.970000000, 5518.390000000   UNION ALL  SELECT '1/11/2000 12:00:00 AM', 5513.040000000, 5537.690000000, 5221.280000000, 5296.300000000   UNION ALL  SELECT '1/12/2000 12:00:00 AM', 5267.850000000, 5494.300000000, 5267.850000000, 5491.200000000 GO  CREATE VIEW MyView  AS SELECT T1.*,     CalculatedColumn = Col3 -        (SELECT Col3 FROM MyTable Q2        WHERE Q2.MyDate = (SELECT MAX(Q1.MyDate)                            FROM MyTable Q1                            WHERE Q1.MyDate < T1.MyDate)     ) FROM MyTable T1 GO  SELECT * FROM MyView GO 

    Results

    MyDate                  Col2      Col3      Col4      Col5      CalculatedColumn ----------------------- --------- --------- --------- --------- ---------------- 2000-01-03 00:00:00.000 5209.5400 5384.6600 5209.5400 5375.1100 NULL 2000-01-04 00:00:00.000 5533.9800 5533.9800 5376.4300 5491.0100 149.3200 2000-01-05 00:00:00.000 5265.0900 5464.3500 5184.4800 5357.0000 -69.6300 2000-01-06 00:00:00.000 5424.2100 5489.8600 5391.3300 5421.5300 25.5100 2000-01-07 00:00:00.000 5358.2800 5463.2500 5330.5800 5414.4800 -26.6100 2000-01-10 00:00:00.000 5617.5900 5668.2800 5459.9700 5518.3900 205.0300 2000-01-11 00:00:00.000 5513.0400 5537.6900 5221.2800 5296.3000 -130.5900 2000-01-12 00:00:00.000 5267.8500 5494.3000 5267.8500 5491.2000 -43.3900 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 11 records in the Menu table, only 1 with a PageID set
I have date range data in SQL DB table that has these three (only
I'm working on dashboard application where I have to retrieve a set of records
I have a table which contains due dates for individual member records. Each row
I have two tables Settlement and Violations.SettlementID is primary Key in Settlements table and
I am trying to set up an sql table which records when an account
I have a set of records in Microsoft Access that I am trying to
I have a set of records in a panel grid where I want to
I have a set of records, stored as XML files, where the XML files
I have a set of records indexed by id numbers, I need to convert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.