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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:24:45+00:00 2026-05-17T22:24:45+00:00

I have a table some thing like as follows for Inventory details. InventoryTable. InventoryTableID

  • 0

I have a table some thing like as follows for Inventory details.

InventoryTable.

InventoryTableID  DateCreated  quantity  ItemName
-------------------------------------------------
1                 2010-02-04   12        abc
2                 2010-03-10   4         abc
3                 2010-03-13   5         xyz
4                 2010-03-13   19        def
5                 2010-03-17   15        abc
6                 2010-03-29   15        abc
7                 2010-04-01   22        xyz
8                 2010-04-13   5         abc
9                 2010-04-15   6         def    

from the above table if my admin wants to know the inventory details for month April 2010 (i.e. Apr 1st 2010 – Apr 30th 2010)

I need the output as shown below.

  1. inventory as on Apr 1st 2010

    ItemName  Datecreated   qty
    ----------------------------
    abc       2010-03-29    15
    xyz       2010-04-01    22
    def       2010-03-13    19
    
  2. inventory as on Apr 30th 2010

    ItemName  Datecreated  qty
    ---------------------------
    abc       2010-04-13   5
    xyz       2010-04-01   22
    def       2010-04-15   6
    
  • 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-17T22:24:46+00:00Added an answer on May 17, 2026 at 10:24 pm

    For your first result set, run with @YourDataParam = ‘2010-04-01’. For the second set, use ‘2010-04-30’.

    ;with cteMaxDate as (
        select it.ItemName, max(it.DateCreated) as MaxDate
            from InventoryTable it
            where it.DateCreated <= @YourDataParam
            group by it.ItemName
    )
    select it.ItemName, it.DateCreated, it.qty
        from cteMaxDate c
            inner join InventoryTable it
                on c.ItemName = it.ItemName
                    and c.MaxDate = it.DateCreated
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a table structure that looks something like this(some details omitted): ColumnName
I have a table in Oracle 10g that contains some information as follows: SQL>
I have a table like follows: Potion { id, name, freq } I gave
I have a table - something like: A|B 1|1 1|2 1|3 2|1 2|3 2|4
I have a table that looks something like this: word big expensive smart fast
I have a table that looks something like this: id | firstperson | secondperson
I have a table that looks something like this: Name Year Value A 2000
I have a relationships table, the table looks something like this ------------------------ | client_id
Let's say I have a MySQL table that is something like this: software table:
Suppose I have a table of users. Something like: ID integer, USER text, POSITION

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.