Skip to content
Advertisement

How to use result of SELECT in a limit

I have a table here that keeps repeating results over environments.

Cf :

… etc etc.

I tried to use a group by but as there are slight changes in the encoding, it’s not really effective. I tried to specify an environment too but from a machine to another, it changes. But I do have a Column named ” Ordinal_Position ” that gives a sort ID and that repeats too.

What I’d like to do is use it as a Single Value in my limit. here I show you my query :

The limit instruction asks me a “Single Value” in order to work. isn’t it possible to create a variable or something like that ? I tried to work with “AS” and “WITH” but I’m not getting any results.

PS : I’m in DB2, in an Iseries environment, and Syscolumns is an generated automatically by the system

Advertisement

Answer

Are you trying to get column information for the table from first available schema (environment)? Try this

To use result of select to limit rows, you can try this

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