0

I'm trying to use my knowledge of SQL to write queries for AutoId for SAP, and I'm not sure what flavor of SQL I should be using? Like Microsoft SQL Server or Oracle, because I'm not too familiar with ABAP or what SQL Syntax the SAP SQL database server requires.

For example even "Select Random", do I do it like

SELECT column FROM  
(SELECT column FROM table  
ORDER BY dbms_random.value)  
WHERE rownum =1  

or

SELECT TOP 1 column FROM table  
ORDER BY NEW ID()  

Some people are just putting simply SELECT RANDOM but I'm not sure that is right, because that's not how I was doing it before when writing queries in anywhere else.

Query id - 1 
FROM LFB1 INNER JOIN LFA1 ON LFB1~LIFNR = LFB1~LIFNR 
WHERE ZWELS (output X) (Value L)
SELECT RANDOM
LIFNR (output X)
T005T (output X)

Query id -2 
SELECT RANDOM
WHERE SAKNR (output X)
AND WAERS (output X)
FROM LFB1 INNER JOIN LFA1 ON LFB1~LIFNR = LFB1~LIFNR 

This is a weird way to write SQL code, this program AutoId for SAP and it is new for me. That is why it looks strange. I have to make the code in an Input Script using EXCEL. I'm hoping to find someone with experience using it.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • Hi Sarah. SAP uses `OpenSQL`, and though I'm not familiar with it either, there are some tutorials available on line. I also changed the tags on your question to see if anyone with `OpenSQL` knowledge might latch on, but it's not a heavily used tag here. – Eric Brandt Jun 06 '19 at 18:51
  • Possible duplicate of [Open SQL equivalent for ROW\_NUMBER()](https://stackoverflow.com/questions/23559808/open-sql-equivalent-for-row-number) – Suncatcher Jun 07 '19 at 06:03

0 Answers0