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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:17:49+00:00 2026-06-17T06:17:49+00:00

I have been trying to figure out how to pull data out of sql

  • 0

I have been trying to figure out how to pull data out of sql table that holds the history of price changes for items in inventory. Example of how the data is laid out is below:

Item No   Date changed   Price
1         11/20/2012     15
2         11/28/2012     25
1         12/1/2012      18

I am needing to pull the last entry for each item no so that i can find where prices have change by more than a certain percent. Once I get the information all worked out but i am not sure how to pull only the last two updates for each item. Any help will be greatly appreciated

  • 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-17T06:17:50+00:00Added an answer on June 17, 2026 at 6:17 am

    This is how i got it to work.
    create table ##inventoryitems (ID INT Identity(1,1),itemno char(11));

    insert into ##inventoryitems
    select distinct itemno
    from InventoryActPkgCostHist
    where LocID=3

    create table ##temptable (item# char(11),changedate datetime,price numeric(8,2));

    DECLARE @Counter INT
    SET @Counter = 1
    while @Counter<=(select COUNT(*) from ##inventoryitems)

    begin
    insert into ##temptable
    select top 2 i.itemno,i.ActPkgCostDate,i.ActPkgCost
    from InventoryActPkgCostHist i join ##inventoryitesm temp on i.itemno= temp.itemno
    where temp.id=@Counter and locidd=3
    order by itemno,ActPkgCostDate desc

    set @Counter=@Counter+1

    end

    Thank you for everyone’s help

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

Sidebar

Related Questions

I have been trying to figure out how to associate data with the event
I have been trying to figure out why me matchers aren't matching, and that's
I have been trying to figure out why this PL/SQL purge script runs slowly
I have been trying to figure out why I am getting this problem and
I have been trying to figure out how to read paragraph content which exists
I have been trying to figure out how to open a file from the
I have been trying to figure out a solution but nothing has really presented
I have been trying to figure out a way to tag several methods from
I have been trying to figure out why and how to use performSelector. I
I'm a bit new to js and have been trying to figure out how

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.