Sunday, 15 March 2015

sql server - create dummy column in a query that its value come from a condition -


I am creating a query that I will use it in crystal reports that the query is working fine but I I want to add another column (dummy column) which will be filled on a condition basis, the query is:

  Actcode, Actnet, Segment 0 + '-' + Segment_1 ActName, Max (Refraat) , Minimum (Refdate), Debt as Debit, TD in Deposits (TD) as Credit from Oact T .Actcode = Submit as GDT 1 T1 on T1. Account where ('Segment like' segment like '01% 'or '02%' or 'Segment like' '03% ') and (T. 0. Segment_1 =' 01 ') and (' 2014-01-31 'And' 2015-12-27 'refdate) by Actctod, Actnet, Segment_0, Segment, by order ectcode  

If the segment starts with' 01 'then dummy The value in column will show 'A' if the segment_0 starts with '02' then the value will show 'L' in the dummy column. 'If Segment starts with 0' 03 'then dummy column will show the value' E 'if I tried to use the statement, and the case but luck was not on my side: (

No comments:

Post a Comment