in urgent need of query
-
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
-
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
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
-
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
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 meterIDThis 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
-
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
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