EmilyPaterson
Technical User
Hi all,
I'm quite new to SQL, so please bear with me.
I've managed to write some code which does what I want it to do, but it is taking a really long time to process. I don't fully understand the process SQL goes through to execute a query, so I was hoping that someone could help me combine/simplify the process and make the run time shorter.
Essentially what I'm trying to do is update a table with an index of whether the windspeed for a given event is above a given threshold or below. The code I wrote takes approx 1 hour to run currently for each threshold, except that I have over 50 thresholds, so as you can imagine, it's taking a long time to run.
Here's the code that I've written (I've only included 3 thresholds for sake of simplicity):
update dbo.Event_WindSpeed
SET WS_200 = (CASE WHEN (PEAKGUST >= 200) THEN 'OVER' ELSE 'UNDER' END);
update dbo.Event_WindSpeed
SET WS_210 = (CASE WHEN (PEAKGUST >= 210) THEN 'OVER' ELSE 'UNDER' END);
update dbo.Event_WindSpeed
SET WS_220 = (CASE WHEN (PEAKGUST >= 220) THEN 'OVER' ELSE 'UNDER' END);
Thanks!
I'm quite new to SQL, so please bear with me.
I've managed to write some code which does what I want it to do, but it is taking a really long time to process. I don't fully understand the process SQL goes through to execute a query, so I was hoping that someone could help me combine/simplify the process and make the run time shorter.
Essentially what I'm trying to do is update a table with an index of whether the windspeed for a given event is above a given threshold or below. The code I wrote takes approx 1 hour to run currently for each threshold, except that I have over 50 thresholds, so as you can imagine, it's taking a long time to run.
Here's the code that I've written (I've only included 3 thresholds for sake of simplicity):
update dbo.Event_WindSpeed
SET WS_200 = (CASE WHEN (PEAKGUST >= 200) THEN 'OVER' ELSE 'UNDER' END);
update dbo.Event_WindSpeed
SET WS_210 = (CASE WHEN (PEAKGUST >= 210) THEN 'OVER' ELSE 'UNDER' END);
update dbo.Event_WindSpeed
SET WS_220 = (CASE WHEN (PEAKGUST >= 220) THEN 'OVER' ELSE 'UNDER' END);
Thanks!