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

  • Home
  • SEARCH
  • 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 8890757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:34:31+00:00 2026-06-14T22:34:31+00:00

Here are my two queries SELECT EWND.Position, NKey = CASE WHEN ISNULL(Translation.Name, ”) =

  • 0

Here are my two queries

SELECT EWND.Position,
NKey = CASE WHEN ISNULL(Translation.Name, '') = '' THEN EWND.Name
ELSE  Translation.Name END, Unit = EW_N_DEF.Units                               
FROM EWND
INNER JOIN EW_N_DEF ON EW_N_DEF.Nutr_No = EWND.Nutr_No
LEFT JOIN Translation ON Translation.CodeMain = EWND.Nutr_no
WHERE Translation.CodeTrans  = 1
ORDER BY EWND.Position

And this is the unpivot one

SELECT * 
FROM 
   (SELECT N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27,N28,N29,N30,N31,N32,N33,N34
   FROM EWNVal WHERE Code=6035) Test
UNPIVOT
   (Value FOR NUTCODE IN 
      (N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27,N28,N29,N30,N31,N32,N33,N34)
)AS test

The output of the queries are like this:

  Position Name         Unit
    1   Calories    
    2   Protein g
    3   Total Fat           g
    4   Total Carbs         g
    5   Calories from Fat   
    6   Saturated Fat       g
    7   Trans Fat           g
    8   Monounsaturated Fat g
    9   Polyunsaturated Fat g   

And

Value Code
    0   N1
    0   N2
    0   N3
    0   N4
    0   N5
    0   N6
    0   N7
    0   N8
    0   N9

The output must be like this

1   Calories                0   N1
2   Protein             g   0   N2
3   Total Fat           g   0   N3
4   Total Carbs         g   0   N4
5   Calories from Fat       0   N5
6   Saturated Fat       g   0   N6
7   Trans Fat           g   0   N7
8   Monounsaturated Fat g   0   N8
9   Polyunsaturated Fat g   0   N9

Both Queries put out same number of rows but not columns, Is it possible to join this two? I tried the union but it has problems that I cant solve

Thanks in advance!

  • 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-06-14T22:34:32+00:00Added an answer on June 14, 2026 at 10:34 pm

    If your data from the two queries is joinable based on the numeric portion of the Code and Position then you might be able to use something like this:

    select q1.position,
      q1.name,
      q2.value,
      q2.code
    from
    (
      SELECT EWND.Position,
        NKey = CASE WHEN ISNULL(Translation.Name, '') = '' THEN EWND.Name
                    ELSE  Translation.Name END, Unit = EW_N_DEF.Units                               
      FROM EWND
      INNER JOIN EW_N_DEF 
        ON EW_N_DEF.Nutr_No = EWND.Nutr_No
      LEFT JOIN Translation 
        ON Translation.CodeMain = EWND.Nutr_no
      WHERE Translation.CodeTrans  = 1
    ) q1
    full outer join
    (
      SELECT value, code
      FROM 
      (
         SELECT N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27,N28,N29,N30,N31,N32,N33,N34
         FROM EWNVal 
         WHERE Code=6035
      ) Test
      UNPIVOT
      (
        Value FOR NUTCODE IN 
            (N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27,N28,N29,N30,N31,N32,N33,N34)
      )AS test
    ) q2
      on q1.Position = right(q1.code, len(q1.code)-1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here are two example queries: SELECT NOW(), NOW() + INTERVAL 1 HOUR + INTERVAL
Here are two sqlite queries: SELECT * FROM items JOIN licenses ON items.id=licenses.id OR
Here are two simple queries: SELECT EntityID, EntityName FROM EntityRelations.Entities WHERE EntityID IN (SELECT
I have this two queries: SELECT `a`.*, `b`.`id` AS host_id, SUM(CASE WHEN c.event_id IS
Here are two queries that return the same resultset, but which is the optimal
So two questions here: If I use <input type=button onclick=validate()> then the enter key
Here total two union binding three queries, first query retrieving records from a virtual
Update take 2 here is the two queries i'm working with (paging is omitted
This is for Android SQLite. I have two queries like this: select * from
The issue here is suppose if i want to use two queries seperated by

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.