Click here to Skip to main content
15,039,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need sql query on below scenario

I have a table with levels 0 t0 3 and [check at Lvl 1] is having Valid lvl 1 and Invalid lvl 1 at lvl 1 , I need [Check at level 2] as output if lvl(column B) is 1 and [check at Lvl 1] is Valid lvl 1 then make [check at level 2] as valid lvl 2 at lvl 2 position and if lvl(column B) is 1 and [check at Lvl 1] is Invalid lvl 1 then make [check at level 2] as Invalid lvl 2 at Lvl 2 position and if there is no lvl 1 before 2 then make as Invalid lvl 2 at level 2 position.

ABC	    Lvl	Check at LVL 1	Check at Level 2
1EC80AV	  0		
1EC80AV	  2		           Invalid Lvl 2
1EC80AV	  1	Valid Lvl 1	
1EC80AV	  2		           Valid Lvl 2
1EC80AV	  2		           Valid Lvl 2
1EC80AV	  1	Invalid Lvl 1	
1EC80AV	  2		           Invalid Lvl 2


What I have tried:

I tried with left join but not getting correct results
Posted
Updated 12-Apr-21 1:29am
v3
Comments
OriginalGriff 12-Apr-21 4:30am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.
CHill60 12-Apr-21 5:54am
   
You might want to consider using punctuation and quotation marks in order to make that text readable too!
RedDk 12-Apr-21 13:16pm
   
Same question posted seven times since December 15, 2020 ... (just saying) :)

1 solution

It sounds like you should use TRIGGERS for this. Also, as described, everything is really controlled by level 1.

You can learn about triggers for AFTER (INSERT, UPDATE) Here are some sources which you can pick through to determine which one you can learn from most easily: Google[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900