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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:24:55+00:00 2026-06-12T17:24:55+00:00

Warning: vagueness & unclear questioning will abound because I know squat about databases. I

  • 0

Warning: vagueness & unclear questioning will abound because I know squat about databases.

I just discovered that I need to use views as surrogates for a cronned update statement. I can somewhat get the view to work, but I’m having trouble with rows.

This post helped me to bang out the update I need, but now that I know that views can run that update whenever it’s needed rather than on a cron schedule, how can I set the view’s column value based upon the view’s row id or equivalent?

I’ve got the select I need:

 SELECT SUM( table2.column1/ (

 SELECT table2constant
 FROM table3
 )
 FROM table2
 WHERE table2table1id = table1id

table1id is the AI id column for table1. table2table1id is PKd to table1id. I’d like the view to have a column PKd to table1id like with table2, and the view needs to have every distinct table1id represented.

I’m sure the jargon’s way off, but hopefully you can see what I need.

Will provide as many edits as necessary for clarity.

Many thanks in advance!

EDIT1

Should I create a trigger that creates the view upon insert to table1? Just found about materialization which is what I need/want?

Clarity

I need a summed value for each table1.table1id

Progress

With this code, I’m getting the first id from table1 and only the total sum. I need a sum for each table1.id.

CREATE VIEW db1.sums as 

SELECT SUM( table2.column1/ (

 SELECT table2constant
 FROM table3
 ) as theSum, table1id
 FROM table1, table2
 WHERE table2.table2table1id = table1.table1id
  • 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-12T17:24:56+00:00Added an answer on June 12, 2026 at 5:24 pm

    To be clear I’m still not sure what you’re trying to accomplish here but if what you posted works, try

    SELECT table1.table1id,
        SUM( table2.collumn1 ) / (SELECT table2constant FROM table3 ) as theSum
     FROM table1, table2
     WHERE table2.table2table1id = table1.table1id GROUP BY table1.table1id
    

    you can replace (SELECT table2constant FROM table3 ) with your constant if it has no reason to otherwise be in the database (if it’s not updated)

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

Sidebar

Related Questions

WARNING: I was just informed by another user that there are some legal issues
Warning: Note that this is a dumb question of something that I would probably
Warning: This is inherited legacy code that was initially put together in the early
WARNING: RubyGems 1.2+ index not found for: RubyGems will revert to legacy indexes degrading
Warning : No -setContents method found. messages without a matching method signature will be
I'm hesitant to ask this question because of the vagueness of the situation, but
Warning - I am very new to NHibernate. I know this question seems simple
Warning: This is a not very serious question/discussion that I am posting... but I
Warning: Noob here. I know this is a trivial subject but I'm having a
Warning: I have no clue about how to work with XML. I have 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.