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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:27:31+00:00 2026-06-12T23:27:31+00:00

I want to select the views, increase and percentage increase from a table but

  • 0

I want to select the views, increase and percentage increase from a table but only show the unique id’s. I can get the information what I want but it’s more then I need and can’t narrow the results.

I have the following data:

+------------+------------+-------+-------+
| datum      | youtube_id | views | likes |
+------------+------------+-------+-------+
| 2012-10-07 |     123456 |   100 |   100 |
| 2012-10-07 |      98765 |   200 |   200 |
| 2012-10-08 |     123456 |   150 |   150 |
| 2012-10-08 |      98765 |   300 |   300 |
| 2012-10-09 |     123456 |   300 |   300 |
| 2012-10-09 |      98765 |   500 |   500 |
+------------+------------+-------+-------+

And the following sql statement:

SELECT 
id, 
startcount, 
endcount, 
(endcount - startcount)increasing, 
((endcount - startcount) / ( startcount ) *100)percentChange
FROM (SELECT youtube_id AS id, views AS startcount
    FROM charts
    WHERE datum =  '2012-10-08')startRange,
(SELECT views AS endcount
FROM charts
WHERE datum =  '2012-10-09')endRange

This gives me the following result:

+--------+------------+----------+------------+---------------+
| id     | startcount | endcount | increasing | percentChange |
+--------+------------+----------+------------+---------------+
| 123456 |        150 |      300 |        150 |      100.0000 |
|  98765 |        300 |      300 |          0 |        0.0000 |
| 123456 |        150 |      500 |        350 |      233.3333 |
|  98765 |        300 |      500 |        200 |       66.6667 |
+--------+------------+----------+------------+---------------+

The expected result would be:

+--------+------------+----------+------------+---------------+
| id     | startcount | endcount | increasing | percentChange |
+--------+------------+----------+------------+---------------+
| 123456 |        150 |      300 |        150 |      100.0000 |
|  98765 |        300 |      500 |        200 |       66.6667 |
+--------+------------+----------+------------+---------------+

I have been looking at a group by or a join but can’t figure this out, already redoing this for a few days now but running into a loop myself.

If someone can point me to the right direction or help me out that would be great!

  • 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-12T23:27:38+00:00Added an answer on June 12, 2026 at 11:27 pm

    SQL Fiddle

    SELECT 
        c1.youtube_id id, 
        c1.views startcount, 
        c2.views endcount, 
        c2.views - c1.views increasing, 
        (c2.views - c1.views) * 100 / c1.views percentChange
    FROM 
        charts c1
        inner join
        charts c2 on c1.youtube_id = c2.youtube_id
    WHERE 
        c1.datum = '2012-10-08' and c2.datum =  '2012-10-09'
    

    Edit: changed the increasing

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

Sidebar

Related Questions

I want to select a view from my sys user, but with other connection.
I want to make a view where I can select multiple items from listview
i have users table and i have posts table i want select from users
I can list all views in SQL Server 2008 by using SELECT * FROM
i have a html select with options in my views . onchange i want
i have this lists, and i want select li element from jquery when the
I want to create a landscape view with 2 table views side by side,
i have a database table with a list of sql views i want to
I am using navigation controller and have table views inside views. when i select
Just want to get some views/possible leads on an issue I have. I have

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.