Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Script or Dababase Query

$
0
0

Hello,

I'm not sure how I'd accomplish the following. I appreciate any assistance you can give.

When column NewRevRequired = Yes; I need to get the last revision code in desc order and afterwards increment to the next higher code.

When column NewRevRequired = No; I need to get the last revisioncode in desc order.

Below is a sampling of the code.

When NewRevRequired = Yes
  
   ** Get the last revision in desc order and increment by one.
   Select TOP 1 RevRevision
     case RevReVision
        when 'A' then 'B'
        when 'B' then 'C'
        when 'C' then 'D'
     end 
   FROM DOCUMENTRECORDS_67
   where RevProductCode = '#PartProdCode#'
   ORDER BY RevRevision desc


ELSE


When NewRevRequired = No
  
   ** Get the last revision in desc order.
   Select TOP 1 RevRevision
   FROM DOCUMENTRECORDS_67
   where RevProductCode = '#PartProdCode#'
   ORDER BY RevRevision desc


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>