Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have the following SQL statement:

 

SELECT tbMeasurement.MonitoredEntityCode, CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_1' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_1' 
                       ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_2' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_2'
                           ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_3' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_3' 
                               ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_4' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_4' 
                                   ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_5' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_5' 
                                       ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_6' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_6' 
                                           ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_7' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_7' 
                                               ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_8' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_8' 
                                                   ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'EMISSION_POINT_9' THEN tbMeasurement.NumericResult END AS 'EMISSION_POINT_9' 
                                                    ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'FUGITIVE_TOTAL' THEN tbMeasurement.NumericResult END AS 'FUGITIVE_TOTAL' 
                                                        ,CASE WHEN tbMeasurement.MonitoredLocationCode = 'ACCIDENTAL_TOTAL' THEN tbMeasurement.NumericResult END AS 'ACCIDENTAL TOTAL',
                        tbMeasurement.SampleID, tbMeasurement.ParameterCode, tbParameter.ParameterDescription, 
                            tbMeasurementExtraData.M_C_E, tbMeasurementExtraData.MethodCode, 
                               tbMeasurementExtraData.Description 
                   FROM (tbMeasurement INNER JOIN 
                 tbParameter ON tbMeasurement.ParameterCode = tbParameter.ParameterCode) INNER JOIN 
                     tbMeasurementExtraData ON (tbMeasurement.ParameterCode = tbMeasurementExtraData.ParameterCode) 
                      AND (tbMeasurement.SampleID = tbMeasurementExtraData.SampleID) 
                          AND (tbMeasurement.MonitoredLocationCode = tbMeasurementExtraData.MonitoredLocationCode) 
                              AND (tbMeasurement.MonitoredEntityCode = tbMeasurementExtraData.MonitoredEntityCode) 

 

As you can see I as using a Case statement to create a new column for each type of emission point found and for Fugitive and Accidental Totals. What I am also trying to do is to replace the null values returned for Fugitive and Accidental Totals with a 0. I have tried using an inner case statement but that doesn't seem to work, any suggestions? I have also tried the replace statement, no effect.

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...