Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6941593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:54:21+00:00 2026-05-27T12:54:21+00:00

My dataset is not exactly like EAV format, but it’s somewhat similar; here’s the

  • 0

My dataset is not exactly like EAV format, but it’s somewhat similar; here’s the data:

original data

In the format I need is as follows:

data format needed

For every EN_NO group I need the data in above format. If group on EN_NO > 1 then respestive product key should go to respestive product column otherwise not (for e.g. EN_NO 4 and 5).

I hope I am clear. Data is in a Qracle table, please suggest a query to get the data in the format I need.

Thanks,
Prakash

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:54:22+00:00Added an answer on May 27, 2026 at 12:54 pm

    I would highly recommend altering your table structure. At present you have two pieces of information tied into a single field. This is a SQL Anti-Pattern and destroys the ability of Oracle to user certain optimisations.

    Instead, please consider splitting “PROD_KEY” into two fields (PRODUCT_TYPE = Prod_A, etc) (SUB_PRODUCT_ID = 1, 2, 3, etc). Or, to cause less potential change across the database, simply add the PRODUCT_TYPE to your current table.

    That said, using your current structure…

    SELECT
      EN_NO,
      PROD_KEY,
      CASE WHEN (EN_NO < 4) AND (LEFT(PROD_KEY, 6) = 'Prod_A') THEN PROD_KEY ELSE NULL END AS Prod_A,
      CASE WHEN (EN_NO < 4) AND (LEFT(PROD_KEY, 6) = 'Prod_B') THEN PROD_KEY ELSE NULL END AS Prod_B,
      CASE WHEN (EN_NO < 4) AND (LEFT(PROD_KEY, 6) = 'Prod_C') THEN PROD_KEY ELSE NULL END AS Prod_C,
      PROD_QTY
    FROM
      yourTable
    

    This works when you know specifically what columns you need as output. If you need the code to adapt to having Prod_D, etc, then you need to write code that writes code (Dynamic SQL).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem Constraints Size of the data set, but not the data itself, is known.
I need to create an match-finder system for some data set, as follows: There
Not exactly sure what to call this, but in SQL I often find myself
Not sure if what am trying to do is bad but here's my question:
Imagine you have a large dataset that may or may not be filtered by
Can mysql handle a dataset of 50gb (only text) efficiently ? If not, what
[...] public DataSet ReturnPromoMagazinesDs() { MySql.Data.MySqlClient.MySqlConnection mysqlConnection = new MySql.Data.MySqlClient.MySqlConnection(this.connectionString); MySql.Data.MySqlClient.MySqlCommand mysqlCommand = new
I have a data set that looks like the following. EMPLID PHONE_TYPE PHONE ------
Does anyone know a way to make a strongly typed dataset (Hey not my
I'm passing parameters (over 30 in all) from a system.data.dataset into a tableadapter insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.