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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:46:41+00:00 2026-06-11T05:46:41+00:00

Possible Duplicate: Sql Query throwing error I am trying a query for retrieving records

  • 0

Possible Duplicate:
Sql Query throwing error

I am trying a query for retrieving records according to divisions and display according to months and i have to sum up the salary allowance month wise, nd also show them month wise.

Here’s the query im trying :-

select  
    pmc.[month] as 'Month', 
    pmc.pd_name_of_project as 'Name of Project',
    tbl_div.name AS 'Name of Advisory Services Division',
    TBL_PMC_UNIT.UNIT_NAME AS 'Name of Unit',
    pmc.pd_project_type as 'Project Type',
    pmc.accepted_tender_cost as 'Accepted Tender Cost',
    pmc.work_order_date as 'Work Order Date',
    pmc.tender_period_months as 'Tender Period',
    pmc.project_completion_date as 'Project Completion Date',
    pmc.per_pmc_charges as '% Of PMC Charges',
    pmc.total_pmc_charges_scheme as 'Total PMC amount   of the Scheme',
    pmc.bill_amount_certified_upto_previous_month as 'Bill amount certified upto previous Month',     
    pmc.total_PMC_charges_upto_previous_month as 'Total PMC charges  upto previous Month',
    pmc.receipt_PMC_charges_upto_previous_month as 'Receipt of PMC Charges upto previous Month',
    pmc.balance_of_PMC_charges_upto_previous_month as 'Balance of PMC charges upto previous Month',
    pmc.bill_amount_certified_current_month as 'Bill amount certified During Current Month',
    pmc.PMC_charges_for_current_month as ' PMC charges  During Current Month',
    pmc.receipt_PMC_charges_current_month as 'Receipt of PMC Charges During Current Monthh',
    pmc.balance_of_PMC_charges_current_month as 'Balance of PMC charges During Current Month',
    SUM(pmc.salary_allowance) as 'Salary & Allowance Division'
FROM 
    TBL_PMC pmc 
        INNER JOIN TBL_DIV 
            ON TBL_DIV.ID = pmc.DIV_ID
        LEFT OUTER JOIN TBL_PMC_UNIT 
            ON TBL_PMC_UNIT.ID=pmc.UNIT_ID  
WHERE 
    pmc.div_id= 17 
    --and pmc.unit_id=@unit_id;
group by  
    pmc.[month]

Im having the following error :-
Column ‘TBL_PMC.pd_name_of_project’ is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
I dont want to use aggregate functions on all columns….just a few columns i have to sum up!!

  • 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-11T05:46:42+00:00Added an answer on June 11, 2026 at 5:46 am

    With the GROUP statement you can use columns in the SELECT which are contained in the GROUP BY or has an aggregate function. – as the error message said.

    You can try to use the SUM...OVER (PARTITION BY ...) clause in this case. Check MSDN.

    So delete the Group By line and change your sum like this:

    SUM(pmc.salary_allowance) OVER(PARTITION BY pmc.[month])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: SQL Server Database query help Hi, I have a problem that I
im trying to create a sql query, that will detect (possible) duplicate customers in
Possible Duplicate: Parameterizing a SQL IN clause? Hi, I have a query looks like
Possible Duplicate: SQL query to find Missing sequence numbers I have a table which
Possible Duplicate: oracle PL/SQL: sort rows I run this query: Select a.product, sum( case
Possible Duplicate: Duplicate result Interview - Detect/remove duplicate entries I have a SQL Query,
Possible Duplicate: Hierarchical SQL question I have below records to maintain. It has parent
Possible Duplicate: Insert line into a query result (sum) I have a report that
Possible Duplicate: SQL query filtering by list of parameters I have a method ADO.NET
Possible Duplicate: SQL Query to Select First/Top N records Here is my code so

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.