Results 1 to 2 of 2
  1. #1
    Join Date
    May 2013
    Posts
    4

    Unanswered: How to get total Consumption

    Hi All,

    I am stuck in a query to get the total consumption. Well my table sturcture is

    tbl_MeterDetails

    Meterid----BigInt
    reading----BigInt
    read_date----Date
    read_time---Time
    consumption---BigInt
    TotalConsumption---BigInt

    I want the query to find out the consumption meterid wise and read_date wise. And total consumption from the consumption meterid wise and read_date wise.

    Thanks in advance
    Reagrds
    alimdyusuf

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    well first off read_date and read_time should be stroed as one value, like most db system MySQL stores date and time in a single value, what ever you call it is upto you. Id probably use soemthign like TimeofMeterReading.

    total consumption is a derived value (effectively total consumption is DERIVED from the first meter reading (usually on installation) and the current meter reading.

    I don't know what your column "reading" is meant to be

    You've not identified what is your primary key, Im guessign its going to be a composite of MeterID and the DateOfReading


    to find the consumption you need to subtract the previous reading from the current reading

    you'd probably use a sub query for that

    to find totla consumption you would need an opening meter reading. where or how you identify that is up to
    should you have a table for customer
    a table for meters
    a table for customersmeters (if so that would be a good place to store the initial meter reading)
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •