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 9256609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:59:06+00:00 2026-06-18T11:59:06+00:00

How to create table or maybe trigger that doing like this below? Date Data

  • 0

How to create table or maybe trigger that doing like this below?

     Date        Data

   2/6/2013         2
   2/6/2013         1
   2/6/2013         3
   2/6/2013         1
   2/6/2013         0

The table at top will alternately as input for next table below, but only the last input will show at table below. The input will alternately from 2 until 0

Just say the input start from 2 – 1 – 3 – 1 – 0, and only 0 will show on table.
How to make the trigger? 0 only data, not something unique. Only the latest input will show on table. Remember the table below triggered table at top to take the data.
I just want every time new input inserted, the data that already existed delete and only the new input will show

  Data
    0
  • 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. Editorial Team
    Editorial Team
    2026-06-18T11:59:08+00:00Added an answer on June 18, 2026 at 11:59 am

    I think you just want a VIEW that shows the latest value.

    The following would be the query you’d use for your view…

    SELECT TOP 1 Data FROM Table ORDER BY Date DESC
    

    EDIT To do exactly what you want you’d just need a stored procedure for inserting.

    -- Copy old value into history
    INSERT INTO History SELECT * From Table WHERE yourCondition = True
    -- Delete old value
    DELETE FROM Table WHERE yourCondition = True
    -- Insert new value
    INSERT INTO Table VALUES(@Date, @Data)
    

    Now Table will contain only 1 row with the latest value, while History will contain all the old values. This is completely non-standard and irrational, but should be exactly what you want. If you don’t need history you can just remove the first INSERT statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine a database table that looks like this: create table [dbo].[user] ( id int
I want to have a database table that keeps data with revision history (like
For example: create table test (id numeric, t date not null); create trigger test_in
Let's say my table structure looks something like this: CREATE TABLE [dbo].[table1] ( [id]
I know I can do something like this: CREATE TABLE new_table AS ( SELECT
create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
If i have this: CREATE TABLE ftable ( id INT, fvalue VARCHAR(14) ); INSERT
I have a table that will have 500,000+ records. Each record has a LineNumber
I have an article table on a Postgresql 9.1 database and a trigger that
I created a table with this schema using sqlite3: CREATE TABLE monitored_files (file_id INTEGER

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.