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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:05:52+00:00 2026-05-14T02:05:52+00:00

sorry for the bad title, I don’t know how to describe my problem. I

  • 0

sorry for the bad title, I don’t know how to describe my problem.

I have the following table:

    |  ItemID  |    Date    |
    -------------------------
    |    1     |  01.01.10  |
    |    1     |  03.01.10  |
    |    1     |  05.01.10  |
    |    1     |  06.01.10  |
    |    1     |  10.01.10  |
    |    2     |  05.01.10  |
    |    2     |  10.01.10  |
    |    2     |  20.01.10  |

Now I want to GROUP BY ItemID and for the date I want to get the value, which excesses 60%. What I mean is, that for item 1 I’ve five rows, so each have a percentage of 20% and for item 2 I’ve three row, so each have a percentage of 33,33%. So for item 1 I need the 3rd and for item 2 the 2nd value, so that the result looks like that.

    |  ItemID  |    Date    |
    -------------------------
    |    1     |  06.01.10  |
    |    2     |  10.01.10  |

Is there a easy way so get this data? Maybe using OVER?

Thank you
Torben

  • 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-14T02:05:53+00:00Added an answer on May 14, 2026 at 2:05 am
    with NumItems as
    ( select itemID, count(*) as numOfItems from table group by itemID) 
    ),
    rowNums as
    ( 
    select itemID,Date, row_number() over (partition by ItemID order by date asc) as rowNum
    from table
    )
    select itemID, min(Date) from
    rowNums a inner join NumItems b on a.itemID = b.ItemID
    where cast(b.rowNum as float) / cast(numOfItems as float) >= 0.6
    group by itemID
    

    that should do it although I am certain It can be writter with only one table scan. That should work nice though.

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

Sidebar

Related Questions

Sorry for bad english and bad title! I have the table post id title
Sorry for the bad title, but I don't know how to name this. My
Sorry for a title that bad, but i didn't know how to describe my
Sorry for the bad title - I simply do not know what to call
Sorry for the bad title (couldn't think of a better way to describe it)
Sorry for the bad question title. Let's say that I have DateRange class that
At first sorry for my really bad title! If you have a better title
Sorry for the bad title, but I have no idea how to put this
first of all: sorry for bad title, didn't knew how to tell my problem
Sorry for the title I have the following relation, a box belongs to a

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.