Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. in urgent need of query

in urgent need of query

Scheduled Pinned Locked Moved Database
database
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3055467
    wrote on last edited by
    #1

    Hi, I am in Urgent need of query. I have 4 tables: MeterSettings MadeByID ConsumerTypeID AllocatedPowerID MeterID Date 1 2 3 22 5/11/2009 1 1 23 MeterMadeBy ID Company TimeInterval 1 L&T 5 2 ABB 10 3 Rishab 15 ConsumerType ID Type TimeInterval 1 SSI 5 2 MSI 20 3 LSI 30 PowerSanctioned ID Power TimeInterval 1 5kw-10kw 5 2 10kw-15kw 10 3 15kw-20kw 20 4 25kw-30kw 25 now the requirement is I have to get MeterIds and corresponding Time Intervals in the following manner if a Meter is having value for MadeByID in MeterSettings then we have to get TimeInterval of corresponding Meter.otherwise get the TimeInterval of the meter based on value of ConsumerType. Otherwise go for PowerSanctioned. I can't use Stored Procedures for this. The only option is query

    E J 3 Replies Last reply
    0
    • U User 3055467

      Hi, I am in Urgent need of query. I have 4 tables: MeterSettings MadeByID ConsumerTypeID AllocatedPowerID MeterID Date 1 2 3 22 5/11/2009 1 1 23 MeterMadeBy ID Company TimeInterval 1 L&T 5 2 ABB 10 3 Rishab 15 ConsumerType ID Type TimeInterval 1 SSI 5 2 MSI 20 3 LSI 30 PowerSanctioned ID Power TimeInterval 1 5kw-10kw 5 2 10kw-15kw 10 3 15kw-20kw 20 4 25kw-30kw 25 now the requirement is I have to get MeterIds and corresponding Time Intervals in the following manner if a Meter is having value for MadeByID in MeterSettings then we have to get TimeInterval of corresponding Meter.otherwise get the TimeInterval of the meter based on value of ConsumerType. Otherwise go for PowerSanctioned. I can't use Stored Procedures for this. The only option is query

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      Create a OUTER JOIN with all four answers and then use application logic to pick the correct one.

      Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

      1 Reply Last reply
      0
      • U User 3055467

        Hi, I am in Urgent need of query. I have 4 tables: MeterSettings MadeByID ConsumerTypeID AllocatedPowerID MeterID Date 1 2 3 22 5/11/2009 1 1 23 MeterMadeBy ID Company TimeInterval 1 L&T 5 2 ABB 10 3 Rishab 15 ConsumerType ID Type TimeInterval 1 SSI 5 2 MSI 20 3 LSI 30 PowerSanctioned ID Power TimeInterval 1 5kw-10kw 5 2 10kw-15kw 10 3 15kw-20kw 20 4 25kw-30kw 25 now the requirement is I have to get MeterIds and corresponding Time Intervals in the following manner if a Meter is having value for MadeByID in MeterSettings then we have to get TimeInterval of corresponding Meter.otherwise get the TimeInterval of the meter based on value of ConsumerType. Otherwise go for PowerSanctioned. I can't use Stored Procedures for this. The only option is query

        J Offline
        J Offline
        Jondo24shoots
        wrote on last edited by
        #3

        select MS.MadeByID, CT.TimeInterval, PS.TimeInterval
        From MeterSettings AS MS INNER JOIN
        ConsumerType AS CT
        ON MS.ConsumerTypeID = CT.ID
        INNER JOIN PowerSanctioned AS PS
        ON MS.AllocatedPowerID = PS.ID
        WHERE MeterID = enter meterID

        This should be able to select the MadeByID from the MeterSettings table, check and fetch the TimeInterval with the same ID From ConsumerType table and finally gets the TimeInterval From the power sanction table REad More on Joins Jondo

        1 Reply Last reply
        0
        • U User 3055467

          Hi, I am in Urgent need of query. I have 4 tables: MeterSettings MadeByID ConsumerTypeID AllocatedPowerID MeterID Date 1 2 3 22 5/11/2009 1 1 23 MeterMadeBy ID Company TimeInterval 1 L&T 5 2 ABB 10 3 Rishab 15 ConsumerType ID Type TimeInterval 1 SSI 5 2 MSI 20 3 LSI 30 PowerSanctioned ID Power TimeInterval 1 5kw-10kw 5 2 10kw-15kw 10 3 15kw-20kw 20 4 25kw-30kw 25 now the requirement is I have to get MeterIds and corresponding Time Intervals in the following manner if a Meter is having value for MadeByID in MeterSettings then we have to get TimeInterval of corresponding Meter.otherwise get the TimeInterval of the meter based on value of ConsumerType. Otherwise go for PowerSanctioned. I can't use Stored Procedures for this. The only option is query

          J Offline
          J Offline
          Jondo24shoots
          wrote on last edited by
          #4

          select MS.MadeByID, CT.TimeInterval, PS.TimeInterval From MeterSettings AS MS INNER JOIN ConsumerType AS CT ON MS.ConsumerTypeID = CT.ID INNER JOIN PowerSanctioned AS PS ON MS.AllocatedPowerID = PS.ID WHERE MeterID = enter meterID This should be able to select the MadeByID from the MeterSettings table, check and fetch the TimeInterval with the same ID From ConsumerType table and finally gets the TimeInterval From the power sanction table

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups