2

how can I change mySQL code to work in Oracle SQL 11g

SELECT a.boxid, 
GROUP_CONCAT( CONCAT( b.quantity, \' x \', c.name ) SEPARATOR \', \' ) Items
FROM box a
INNER JOIN item_line b ON a.boxid = b.boxid
INNER JOIN items c ON b.itemid = c.itemid

The output of this query looks like this:

boxid     items
1         2 x ball,4 x bat
2         ball
3         3 x cap,2 x ball,bat
4         2 x ball

Thanks for any answers.

0

2 Answers 2

1

use LISTAGG()

SELECT  boxid,
        LISTAGG(quantity || ' x ' || name, ',') 
            WITHIN GROUP (ORDER BY boxid) AS items
FROM    tableName
GROUP   BY boxid
Sign up to request clarification or add additional context in comments.

Comments

0

You can try Oracle's SQL Developer Migration (which is a free product). The docs say it will help migrate Microsoft Access, Microsoft SQL Server, MySQL and Sybase to Oracle:

http://www.oracle.com/technology/tech/migration//workbench/index%5Fsqldev%5Fomwb.html

1 Comment

This link appears to be broken

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.