I have a advanced sql query that I have to do, at least it's advanced for me, I have to put some logic/checks into this statement. I'm unsure exactly where to place this, I think a stored procedure is the only place where you can do/have logic.
I trying to do a query based of these tables:
SQL Tables
CP_BCELP
ID PK, smallint, not null
Unit_Code smallint, not null
StartTS smalldatetime, not null
StopTS smalldatetime, null
Operation_Type varchar(4) , not null
UVD TABLE:
ID PK, smallint, not null
Unit_Code Smallint, not null
Unit_Name Varchar(50)
CE_BCELP
ID PK, smallint, not null
Unit_Code Smallint, not null
EventStartTS smalldatetime, not null
EventEndTS smalldatetime, null
Event_Type char(2), , not null
Avail_Cap decimal(6,2), null
Possible SQL Script
Select Unit_Name, ‘Availability’ =
If CE_BCELP.EventStartTS >CP_BCELP.StopTS Where CE_BCELP.Event_Type = ‘IR’ or CE_BCELP.Event_Type = ‘MB’ or CE_BCELP.Event_Type = ‘RU’ then ‘Availability ‘= Unavailable
If CE_BCELP.EventStartTS >CP_BCELP.StopTS Where
View Complete Post