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

  • Home
  • SEARCH
  • 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 7445155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:45:09+00:00 2026-05-29T11:45:09+00:00

My original data is in Table2. I created Table1 from scratch. I populated Column

  • 0

table

My original data is in Table2. I created Table1 from scratch. I populated Column A like this:

INSERT INTO Table1("item")
SELECT DISTINCT(Table2."item")
FROM Table2

I populated Table1.Totals (Column B) like this:

UPDATE Table1
SET totals = t2.q
    FROM Table1 INNER JOIN
    (
        SELECT t2."item"
        , SUM(t2.quantity) AS q
        FROM t2
        GROUP BY t2."item"
    ) AS t2
    ON Table1."item" = t2."item"

How can I populate Table1.”date”? My UPDATE above doesn’t work here because I can’t use an aggregate function on a date. I was able to get the results I wanted using the following code in a separate query:

SELECT DISTINCT Table1."item"
, Table2."date"
FROM Table1 INNER JOIN Table2
ON Table1."item" = Table2."item"
ORDER BY Table1."item"

But how do I use the results of this query to SET the value of the column? I’m using SQL Server 2008.

  • 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-05-29T11:45:09+00:00Added an answer on May 29, 2026 at 11:45 am

    If you can’t do the insert all over again, as @Lamak suggested, then you could perform an UPDATE this way:

    UPDATE t1
      SET t1.Date = s.Date
      FROM Table1 AS t1
      INNER JOIN 
      (
        SELECT Item, [Date] = MAX([Date]) -- or MIN()
          FROM Table2
          GROUP BY Item
      ) AS s
      ON t1.Item = s.Item;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to insert data from a file into the table Division of
I need to backup the original data from a table so I can fill
original column is like: 0.45::rafas::4.0::0.0::0.9 0.35::rasaf::4.0::110.0::1.0 and i would like to break the string
I have created a table in ASP MVC and populate it with data from
I want to select a bunch of data from a table using a GROUP
I'm aggregating data from one table into another using a query similar to these:
Does the original data type of the username string in a call to FormsAuthentication.SetAuthCookie(...)
I have a page where I submit some data, and return to the original
Original Question What I'd like is not a standard C pre-processor, but a variation
TLDR; How do I read data from a table using Entity Framework, when the

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.