Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

PIVOT and UNPIVOT

HayXingApr 19 2021 — edited Apr 19 2021

I have a table that contain years that and total sales like following

WITH sample_sales_table
AS
  (
  select 2015 FY, 100 SHOE, 50 SHIRT, 2 HAT from dual
  union all
  select 2016, 120, 55, 4 from dual
  union all
  select 2017, 150, 80, 10 from dual
  )
SELECT *
FROM sample_sales_table;

Source of origin table

	FY	 SHOE	   SHIRT	HAT
---------- ---------- ---------- ----------
      2015	  100	      50	  2
      2016	  120	      55	  4
      2017	  150	      80	 10

Possibly 2018, 2019 data
How to create following report ?

WITH sales_report
AS
  (
  select 'SHOE' AS CATEGORY, 100 AS "2015", 120 AS "2016", 150 AS "2017" from dual
  union all
  select 'SHIRT', 50, 55, 80 from dual
  union all
  select 'HAT', 2, 4, 10 from dual
  )
SELECT *
FROM sales_report;

Desired Report output as following:

CATEGORY	 2015	    2016       2017
---------- ---------- ---------- ----------
SHOE		  100	     120	150
SHIRT		   50	      55	 80
HAT		    2	       4	 10

The report may look like this too if new record is added

CATEGORY	 2015	    2016       2017	  2018
---------- ---------- ---------- ---------- ----------
SHOE		  100	     120	150	   180
SHIRT		   50	      55	 80	   120
HAT		    2	       4	 10	    15

I have tried with PIVOT / UNPIVOT and with the LISTAGG to for the FY just never get it right.
If someone can help

Thanks

This post has been answered by Paulzip on Apr 19 2021
Jump to Answer

Comments

That isn't a java or jni question.

There is nothing magic in java/jni that allows/prevents that.

You should create a test app that has no java/jni in it and figure out how to dynamically load a dll (presumably what you are doing.)  A windows programming site can help with specifics.

As a suggestion I would suggest that you do the following since it will help debugging problems.

1. Determine the fully qualified path to the dll

2. Use that

3. If the dll fails to load then report that fully qualified path.

1 - 1

Post Details

Added on Apr 19 2021
7 comments
455 views