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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:20:23+00:00 2026-06-01T02:20:23+00:00

I got a model like this: matrices ( matricesID integer; x integer; y integer;

  • 0

I got a model like this:

matrices (
    matricesID integer;
    x integer;
    y integer;
    value float;
)

So there will store many matrices data in that table, now I need to get average value for each matrix edge by edge, i.e. if one matrix is 20 * 30 and had value in (5,3), (5,7), (5,15), (12,4), (17,5), (17,10), I need to get four groups of data, one for all values that x=5, one for all values that x=17, one for all values that y=4 and one for all values that y=15, cause they are the max/min for x and y.

Is there any way to perform this with easy SQL?

Any idea will be appreciated.

BR

Edward
I

  • 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-01T02:20:24+00:00Added an answer on June 1, 2026 at 2:20 am

    This is a guess as I don’t have much experience in the problem domain:

    select matricesID
        , (select avg(value) from matrices where matricesID = a.matricesID and x = a.minx) as avgofminx
        , (select avg(value) from matrices where matricesID = a.matricesID and x = a.maxx) as avgofmaxx
        , (select avg(value) from matrices where matricesID = a.matricesID and y = a.miny) as avgofminy
        , (select avg(value) from matrices where matricesID = a.matricesID and y = a.maxy) as avgofmaxy
    from (
        select matricesID
            , min(x) as minx
            , max(x) as maxx
            , min(y) as miny
            , max(y) as maxy
        from matrices
        group by matricesID
    ) as a
    

    This is running in SQL Server, but the syntax is simple enough that it hopefully runs in whatever DBMS you are using

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

Sidebar

Related Questions

I've got a model that looks something like this: One Account has many Branches,
I've got a set of models that look like this: class Page(models.Model): title =
I've got a model that looks something like this class SecretKey(Model): user = ForeignKey('User',
I've got a model like this def upload_location(instance, filename): return 'validate/%s/builds/%s' % (get_current_user(), filename)
Say I've got a domain model created from C# classes like this: public class
I got a model like this: public class MainModel { public string Id {get;set;}
I've got a model like this: class Talk(BaseModel): title = models.CharField(max_length=200) mp3 = models.FileField(upload_to
Say, I've got a model like this: class Fleet(models.Model): user = models.ForeignKey(User) [...] ship1
I've got a query that looks like this affiliates = User.objects.annotate(referral_count=Count('referrals')) .filter(referral_count__gt=0) But when
I've got a model like this: class Thing(models.Model): property1 = models.IntegerField() property2 = models.IntegerField()

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.