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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:05:01+00:00 2026-05-26T10:05:01+00:00

I am trying to calculate the median from a table with various types of

  • 0

I am trying to calculate the median from a table with various types of data mixed together (I can’t modify the table). Rows 3 and 6 are examples of this data mixed in, and rows 1, 2, 4, and 5 are examples of rows which I legitimately need the data from (WHERE form_id = 1 AND field_id = 1):

id    form_id    field_id    value
1     1          1           200
2     1          1           290
3     1          2           'Delicious Bacon'
4     1          1           320
5     1          1           120
6     2          3           9000000

I understand that I can derive median from a table using the following:

SELECT x.value from form_data x, form_data y
GROUP BY x.value
HAVING SUM(SIGN(1-SIGN(y.value-x.value))) = (COUNT(*)+1)/2;

However, the data mixed in challenges my SQL abilities. How can I find the median of this data, only where form_id = 1 and field_id = 1?

  • 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-26T10:05:02+00:00Added an answer on May 26, 2026 at 10:05 am

    Try this

    SELECT x.value from form_data x, form_data y
    WHERE x.form_id=1 and x.field_id=1 and y.form_id=and y.field_id=1
    GROUP BY x.value
    HAVING SUM(SIGN(1-SIGN(y.value-x.value))) = (COUNT(*)+1)/2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to calculate the number of rows in a table depending on a
I'm trying to calculate the time it takes to receive all data from a
I'm trying to calculate the conditional median of a chart that looks like this:
I'm trying to calculate the median of a (small) set of NSNumbers in an
Trying to calculate sum of checked tr's. var totalqt=0; totalqt=totalqt + $(this).closest(tr).find(#qt).text(); It gets
Im trying to calculate the bitrate from a video, but Im not sure if
I am trying to calculate this if/else statement through the JOption Message window. Prompt
I'm trying to calculate the sum of my columns (column I). From 1 to
I'm trying to calculate the median of a set of values, but I don't
Im trying to calculate a subtotal and a total from a series of values

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.