Can you have a calculated column in a table not a view?

We have a table which contains a series of rows
Key   Effective Date   Value
1       10/Feb/2006     123
1       23/Oct/2006      456
...We have a requirement to store an indicator that tells us which row is the most current and what the end date of the preceding row was so that we get something along the lines of:
Key   Effective Date   Value   Status         End Date
1       10/Feb/2006     123      HISTORY    22/Oct/2006
1       23/Oct/2006      456     CURRENT   NULL
...I can produce this result quite easily using the analytic function LEAD. My question is, is the answer to this problem to create a view over the table that includes the analytic function or is it possible to define a calculated column in a table that would populate/maintain this vale as part of a table definition?
And as I finish writing this I feel I've answered my own question but hey, there's no harm in asking how others have handled this kind of situation.
Cheers
Richard

My bias would be to create a view that did the calculation.
In theory, you could add those additional columns to a table and maintain the data via a set of triggers, but that would be substantially more complicated than the alternatives for little or no benefit.
A third option would be a materialized view. That might be easier to deal with if you want to have different indexing strategies for current and historical records or if the historical data is queried often enough and updated infrequently enough that it ends up being cheaper to do the calculation once during the update rather than every time the query is run.
A fourth option would be to use stored procedures to maintain the data and have that stored procedure expire the current row and add the new row.
Finally, you might consider version-enabling your table using Workspace Manager rather than writing your own code since Oracle has already written all this code for you.
Justin

Similar Messages

  • Layout: can you have both 2 column and 1 column in same doc?

    Can you?

    The tab definition determines whether or not the tab gets leaders. Right
    now you have, probably, one tab defined, and that tab is defined with
    leaders. You need two tabs, first one defined without leaders (to get
    from auto number to head), second one defined with leaders (to get from
    head to page number). I actually like to use another tab in there so the
    leaders all line up and stop before they get to the numbers.
    Kenneth Benson
    Pegasus Type, Inc.
    www.pegtype.com

  • Using ODBC how do you identify a calculated column in a table?

    I've a calculated column in my table. Is there a way to identify that column through ODBC functions? I need to identify the  calculated column and make it read only. The function should support both SQL and Access databases. Please let me know if
    there is a way to find out this column type.

    Hello,
    You can refer to the following article which list some ODBC Scalar Functions which you can used in the T-SQL query statement.For example
    SELECT {fn TRUNCATE( 100.123456, 4)};
    -- Returns 100.123400
    Reference:http://msdn.microsoft.com/en-us/library/bb630290.aspx
    As per my understanding, there is no built in declarative support for read-only columns. You can try to create a UPDATE trigger to achieving this. Or you can create a view with derived column  from the source table. And then users cannot
    update this calculated column on the view.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Can you have too many rows in a table?

    How many rows would you consider to be too many for a single table and how would you re-arrange the data if
    asked?
    any answers?
    sukai

    I have some tables with over 100 million rows that still perform well, and I'm sure much larger tables are possible.  The exact number of rows would vary significantly depending on a number of factors including:
    Power of the underlying hardware
    Use of the table – frequency of queries and updates
    Number of columns and data types of the columns
    Number of indexes
    Ultimately the answer probably comes down to performance – if queries, updates, inserts, index rebuilds, backups, etc. all perform well, then you do not yet have too many rows.
    The best way to rearrange the data would be horizontal partitioning.  It distributes the rows into multiple files; which provides a number of advantages including the potential to perform well with larger number of rows.
    http://msdn.microsoft.com/en-us/library/ms190787.aspx

  • How many playlists can you have or create

    how many playlists can you have or create

    There is no documented limit. 
    Note that Smart Playlists with Live Updating use extra processing, so if you have more than a few dozen of them you may notice a slowdown.
    Some people think they should create a playlist for each album.  If by any chance that is the reason you are asking the question, you will find it is much easier to get to an album via the column browser.

  • How can you modify the displayed columns on a Related Information List?

    How can you modify the displayed columns on a Related Information List? For example, how could you add the "Type" column to the List of columns displayed for Service Requests when you are viewing the Contacts Detail page?
    Thanks

    I'd have to say I think this is one of the biggest flaws in the OnDemand system currently. The solution I have come up with is to create reports and put them in webapplets showing the data I want to show. I have then removed the standard Related Info List Objects and added weblinks to create new records as the button on the List object is also gone.
    Keep in mind that doing this does slow things down a little, so it may not work if you have a big user base.
    RWB.

  • HT204053 can you have multiple apple id's for the family but we all use the same iCloud?

    Can you have multiple apple id's for the family members but we all us the same iCloud account?

    You'll have to have an ID you all share in order to have a shared iCloud account. It would be sensible for each person to have their own ID and their own iCloud account for email and their own data (each would be on their own computer/iOS device or user account on a Mac) and then have a common account which everyone would sign into in System Preferences>Mail, Contacts and Calendars to access shared data.
    You don't want to be all using the email in a common account - if people are using email aliases remember these can't be detached from the account and transferred to another one. Having all your emails mixed up together can be somewhat impracticable.

  • Can you have two Apple IDs on one IPAD? One for school and one for home?

    Can you have two Apple IDs on one IPAD? One for school and one for home?
    If so do you know how to do it?

    It depends on what you want to do.
    You could, for example, have one AppleID for iCloud backup [and therefore message syncing, notes syncing, etc] and a second one for iTunes [music, iBooks, etc].
    But if you are looking for a way to flip everything between different appleIDs, then no.

  • Can you have two apple ids on one mac?

    Can you have two apple ids on one mac? We each have iPhones and want to utilize iCloud.  Is this possible?

    No, in this case the 2 user accounts with its own Apple IDs would be completely seperated.
    If you want to share this things like music and app purchases you will have to to something else.
    1. Create two user accounts on your Mac (user A and user B).
    2. Create two iCloud accounts just for Mail, Contacts, Calendars, Photos, etc. (one for user A and one for user B):
    On your Mac (with Mac OS X Lion or Mountan Lion):
    Settings > Mail, Contacts, Calendars > iCloud > Create an Apple ID (button in left corner)
    On your iPhone, iPad or iPod touch (iOS 5 or later):
    Settings > Mail, Contacts, Calendars > Add Account > iCloud > Get a free @me.com address and create a new Apple ID
    3. It is not recommended because you shouldn't share your Apple ID account information with other people but you could set up your old Apple ID as an account just for store purchases (Apps, Music, ...) so that everyone of you can manage the purchases in their own library (Access is limited to 10 devices). Therefore you have to setup this "old" ID in Settings of your iOS devices (Settings > iTunes & App Store) and in iTunes on your Mac.

  • Can you have two different users with itune accounts on the same computer?

    Can you have two different users with separate itune accounts on the same Ipad?

    Yes, create another user profile on the computer and each user can log into their own profile that way.

  • Can you have two itunes accounts on the same computer?

    Can you have two itunes accounts on the same computer and if so how do you access them without syncing each others music?

    Yes. Use separate iTunes libraries(launch iTunes with the Shift(Windows) or Option(Mac OS X) key held down as needed), or different user accounts on the computer.
    (100648)

  • Can you have multiple itunes accounts on a single computer?  want to open a separate one for our daughter (but we will manage it).

    just got our daughter a new iTouch, but want to try and keep hers separate from our iPhone stuff.  can you have multiple iTunes accounts on a single computer?

    This is all i know but all you can do is just creat a new one for them both and send all the stuff to the one think u can do that i hope it helps

  • Can you have two apple id accounts on one computer??

    Hi all
    Can you have two seperate apple ID accounts on the one computer?? Imessaging wont work between two iphones if both iphones (husband & wife) use same apple ID account. any help appreciated

    Yes, you can. Apple IDs are really not meant to be shared.

  • CAN YOU HAVE TWO I TUNES ACCOUNT ON ONE COMPUTER?

    CAN YOU HAVE TWO I TUNES ACCOUNT ON ONE COMPUTER?

    The problem with making separate accounts is that this is a laptop, so likely not a huge hard drive, and if the three iTunes libraries need to have a lot of the same music (because everyone or two or three like some of the same stuff) you end up with double or triplicate copies of the music on the hard drive eating up drive space. Since they don't use his laptop normally, creating more accounts (with all the associated files and drive space usage each account would eat up) it probably isn't worth it.
    Instead, the best approach is like Chris said, to make playlists for the girls in the main library and then set up the various iPod to either sync everything (if big enough) or sync only specific playlists (if not big enough).
    Alternatively, they can set their iPods to manual syncing and then when Dad is visiting they can hook up their iPods and "shop" the library and drag in whatever they want to add to the iPods and delete what they no longer want.
    Patrick

  • Can you have more than one iTunes account with home sharing, Can you have more than one iTunes account with home sharing

    Can you have more than one itunes account at one time with apple tv

    My understanding is that the home sharing is based off of being on the same Wifi.  So if someone brings their laptop to your house and connects to your Wifi and they have home sharing on they can connect so you can see his/her iTunes library on your iTunes. 
    I haven't tried this though.  We have two laptops at home, both using my iTunes account and I can see each other's iTunes library, which I'm guessing is what you're probably doing now.  I'd be interested to know if my thought above is true. 

Maybe you are looking for

  • Vista on Macbook 2.4Ghz?

    Hi, I am thinking of buying a Macbook 2.4Ghz but I need Windows Vista Running on it as well. So I was wondering if anyone had already tried it out and what they thought about the performance of Vista on it, ignoring the fact that it would be slower t

  • APPLICATION created in Admin BPC client can't see in Office BPC client

    `Hello Gurus, I am an SAP BI Consultant and having around 4 years of experience. I have started to work on BPC 7.5. I have created dimensions and APPLICATION as well successfully. however when i try to open my Microsoft office BPC client, i am able t

  • Not syncing in iCal on all accounts

    Okay: situation: iMac G5 with Leopard, MacBook Pro with Leopard. Input in iCal on the Mac book is okay, it appears a bit later on the iMac. But not the other way round... Have found out it must be something with accounts: I created an new useraccount

  • When will the iPhone 4 get flash support!!

    You know this is really a killer for all iPhone models. Why? just why don't they have this for their hardware. I should be able to access every website via the web.

  • Finder PDF Services Missing

    I used to have two finder services set up so that I could select a number of image documents and have it convert the images to a PDF, or that I could select a PDF and convert it to images. Since upgrading to Lion when it came out, these services have