Skip to content
Advertisement

Oracle using MOD command to set Y/N on INSERT

I’m trying to generate some sample data for the following table see below.

I have functions that can generate a random DATE and timestamp within a date range, which is working fine.

I want to use the MOD command to populate the active field to ‘Y’ OR ‘N’. I want to set every row to active=’Y’ except for every 5th row I want active=’N’ but I’m struggling to get the syntax correct and would be grateful for some help.

Below is my test CASE so far. Thanks in advance to all who answer and your expertise.

Advertisement

Answer

You can use a CASE expression:

db<>fiddle here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement