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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:08:45+00:00 2026-06-08T18:08:45+00:00

i have problem with my sql. i try sum max number in my statement

  • 0

i have problem with my sql. i try sum max number in my statement to be one row but it’s doesn’t works. the warning message show Incorrect syntax near ‘)’.
this is my code:-

select sum(A) from (select t.ticketid, lt.description ticketsource,
c.description tickedcreted,
max_score = isnull(
(select max(si.marks) as max_score
from survey_items si
left join survey_questions sq on (si.question_id = sq.question_id)
left join survey s on (sq.survey_id = s.survey_id
and s.code_interaction= 1)),0
),
sum(si.marks) totalAnswer,

count(t.ticketid) totalticketcreated,
count(t.feedback) totalfeedbackreceived
from  survey_items si
left join lookup_questions lq on (si.item_id = lq.item_id)
left join feedback fb on (fb.feedback_id = lq.feedback_id)
left join ticket t on (t.ticketid = fb.ticketid)
left join survey_questions sq on (si.question_id = sq.question_id)
left join survey s on (sq.survey_id = s.survey_id)
left join lookup_assignedOfficer c on (c.code = t.enteredby )
left join lookup_department ld on t.department_code =ld.code
left join lookup_ticketsource lt on lt.code = s.code_interaction
where t.trashed_date is null and lt.enabled =1 and ld.description is not null
and
((t.assigned_date BETWEEN '7/16/2012' AND '7/16/2012'))
)
  • 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-08T18:08:46+00:00Added an answer on June 8, 2026 at 6:08 pm

    You have to pass an alias name to table when using a result set retrieved from a select statement as a table.

    Try this:

    select sum(A) from 
    (
        select t.ticketid, lt.description ticketsource,
        c.description tickedcreted,
        max_score = isnull(
        (select max(si.marks) as max_score
        from survey_items si
        left join survey_questions sq on (si.question_id = sq.question_id)
        left join survey s on (sq.survey_id = s.survey_id
        and s.code_interaction= 1)),0
        ),
        sum(si.marks) totalAnswer,
    
        count(t.ticketid) totalticketcreated,
        count(t.feedback) totalfeedbackreceived
        from  survey_items si
        left join lookup_questions lq on (si.item_id = lq.item_id)
        left join feedback fb on (fb.feedback_id = lq.feedback_id)
        left join ticket t on (t.ticketid = fb.ticketid)
        left join survey_questions sq on (si.question_id = sq.question_id)
        left join survey s on (sq.survey_id = s.survey_id)
        left join lookup_assignedOfficer c on (c.code = t.enteredby )
        left join lookup_department ld on t.department_code =ld.code
        left join lookup_ticketsource lt on lt.code = s.code_interaction
        where t.trashed_date is null and lt.enabled =1 and ld.description is not null
        and
        ((t.assigned_date BETWEEN '7/16/2012' AND '7/16/2012'))
    ) AS result
    

    Secondly, you tried to find a sum of column A, but column A is not present in the result set.

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

Sidebar

Related Questions

I have a problem with the SQL statement detailed below. The query returns the
I have a problem with an SQL query. SELECT SUM(table_colum) AS value, SUM(value *
I have a problem with a sql-statement. My DB is MySQL 5.1. I have
I try to connect to oracle 11g but I have problem and receive the
I have problem with my SQL query. I try to eject these queries and
I try to build a database failover (ASP classic) but I have problem with
I try to do a migration but i have problem with this query :
I have problem with SQL query. If given order contains items, witch does not
I have a problem with sql (maths). I have a total payable given to
i have a problem with sql query. I need to get list of users.

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.