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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:57:23+00:00 2026-06-17T15:57:23+00:00

Hi have a query that produces the following result? name count 19 – Evening

  • 0

Hi have a query that produces the following result?

  name                       count    
  19 - Evening ACL           1130
  21 - 14 - 16 Provision     585
  81 - HE FT                 458
  85 - HE PT                 233

How can I get so that the query joins the two rows contains ‘HE’. The result I am after is:

  name                    count
  19 - Evening ACL        1130
  21 - 14 - 16 Provision  585
  HE                      691

Here is the query I am using

SELECT 
vc.vc_name,
COUNT(DISTINCT s.s_studentreference) AS 'Count'

FROM

student s
INNER JOIN person p ON p.p_id = s.s_id
INNER JOIN moduleenrolment e ON e.e_student = p.p_id
INNER JOIN module m ON m.m_id = e.e_module
LEFT JOIN valid_codes vc ON vc.vc_code = m.m_mode AND vc.vc_domain = 'moa'

WHERE

LEFT(m.m_reference, 2) IN ('12')


GROUP BY

m.m_mode,
vc.vc_name

ORDER BY

m.m_mode,
vc.vc_name

Thanks

  • 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-17T15:57:23+00:00Added an answer on June 17, 2026 at 3:57 pm

    Try this (Assuming 'HE' has a space on either side);

    select name, count
    from yourTable where charindex(' he ',name)=0
    union
    select 'HE' name, sum(count) as count
    from yourTable where charindex(' he ',name)>0
    

    Another way is;

    select A.name, sum(A.count) as count
    from (
        select case charindex(' he ',name) 
               when 0 then name else 'HE' end name, count
        from yourTable
    ) A
    group by A.name
    order by A.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following LINQ conditional where clause query that produces a result of
Dear all, I have a select query that currently produces the following results: DoctorName
I have a query that creates a result set like this: Rank Name 1
I have a query that produces the following output in a nested set structure:
I have the following MySQL query, which produces the result I want: SELECT `l`.`status`,
I have a query that produces the following results: { data: [ { id:
I have the following query that performs a AND on-demand: var products = //
Here is a silly question. Lets say I have a query that produces for
I have a LinqToEntities query that double produces a subquery when creating the SQL.
I have a linq to sql query that produces duplicates. i can seem to

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.