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 6588299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:01:50+00:00 2026-05-25T17:01:50+00:00

I have written a query in access and now I am trying to write

  • 0

I have written a query in access and now I am trying to write the same in SQL Server I am getting following error:

Msg 164, Level 15, State 1, Procedure OQRY_STEP_1_1, Line 15
Each GROUP BY expression must contain at least one column that is not an outer reference.

My SQL Query is as follows:

SELECT
    ns11.SYS_ID,
    ns11.SUB_NET_ID,
    ns11.TEMP_ID,
    ns11.EQ_ID,
    ns11.NODE_NAME,
    ns11.EQ_NAME,
    ns11.VAR_NAME,
    ns11.VAR_SET,
    ns11.VAR_SUBSET,
    ns11.EQ_TYPE,
    ns11.RHS_RELN,
    ns11.RHS_OBJECT,
    ns11.EQ_TP_OFFSET,
    ns11.RHS_TP_OFFSET,
    ns11.RETAIN,
    nmte.RHS_VAR_SET,
    nmte.RHS_VAR_SUBSET,
    nmte.RHS_VAR_NAME,
    0 AS RHS_VAR_TYPE,
    CASE
        WHEN [asp].[VALUE] = NULL THEN 0
        ELSE [asp].[VALUE]
    END RHS_VALUE
INTO ##OT_STEP_1_1
FROM (##NT_STEP_1_1 ns11
    INNER JOIN ##NT_MASTER_TEMP_EQUATION nmte
        ON (ns11.SYS_ID = nmte.SYS_ID)
            (ns11.SUB_NET_ID = nmte.SUB_NET_ID)
        AND (ns11.TEMP_ID = nmte.TEMP_ID)
        AND (ns11.EQ_ID = nmte.EQ_ID)
        AND (ns11.NODE_NAME = nmte.NODE_NAME)
        AND (nmte.SYS_ID = ns11.SYS_ID)
        AND (nmte.SUB_NET_ID = ns11.SUB_NET_ID))
    LEFT JOIN AMST_SIM_PAR asp ON 
        (nmte.SYS_ID = asp.SYS_ID)
        AND (nmte.SUB_NET_ID = ns11.SUB_NET_ID)
        AND (nmte.RHS_VAR_NAME = asp.VAR_NAME)
GROUP BY
    ns11.SYS_ID,
    ns11.SUB_NET_ID,
    ns11.TEMP_ID,
    ns11.EQ_ID,
    ns11.NODE_NAME,
    ns11.EQ_NAME,
    ns11.VAR_NAME,
    ns11.VAR_SET,
    ns11.VAR_SUBSET,
    ns11.EQ_TYPE,
    ns11.RHS_RELN,
    ns11.RHS_OBJECT,
    ns11.EQ_TP_OFFSET,
    ns11.RHS_TP_OFFSET,
    ns11.RETAIN,
    nmte.RHS_VAR_SET,
    nmte.RHS_VAR_SUBSET,
    nmte.RHS_VAR_NAME,
    0,
    CASE
        WHEN [asp].[VALUE] = NULL THEN 0
        ELSE [asp].[VALUE]
    END
ORDER BY
    CASE
        WHEN [asp].[VALUE] = NULL THEN 0
        ELSE [asp].[VALUE]
    END;

I am not sure why it is not taking 0 in the group by clause?

  • 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-25T17:01:50+00:00Added an answer on May 25, 2026 at 5:01 pm

    I think the GROUP BY ..., 0, ... is the issue here. Try removing that 0 from there. There is no point grouping by a constant.


    Sidenote:

    CASE WHEN [AMST_SIM_PAR].[VALUE] = NULL
    THEN 0
    ELSE [AMST_SIM_PAR].[VALUE]
    END
    

    should be be written with IS NULL instead of = NULL or as:

    COALESCE( [AMST_SIM_PAR].[VALUE], 0 )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a query which works great on my local SQL Server 2005.
I have written this query, $sql = SELECT `candidates`.`candidate_id`, `candidates`.`first_name`, `candidates`.`surname`, `candidates`.`DOB`, `candidates`.`gender`, DATE_FORMAT(NOW(),
I have written a DB2 query to do the following: Create a temp table
I have written a SQL query that works just fine, but am having a
As I had written in title, I have SQL query, run on Oracle DB,
I want to write the following (pseudo) SQL statement in MS Access: Select C
Some of the queries I have written inside MS-Access are getting deleted automatically. And
I've written this SQL query in MS Access: SELECT * FROM Students WHERE name
I have written a query to find similar ids based on tags from a
I have written this query for retrieving data from mysql as below select FeedbackCode,EMailID,FeedbackDetail,

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.