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

The Archive Base Latest Questions

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

I have two tables l & C which are linked by two fields l.mID

  • 0

I have two tables l & C which are linked by two fields l.mID and c.mID the c table holds three types of records cs, ls, & vs with my query I need to select all records from l and as part of the query have three columns showing totals for cs, ls & vs;

SO far I am using an outer join:

SELECT l.*, COUNT(*) FROM l LEFT OUTER JOIN c ON c.mID = l.mID WHERE l.mID = 2

But this just appends one column with a full total any help would be great 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-08T08:08:54+00:00Added an answer on June 8, 2026 at 8:08 am

    You can use a CASE statement in your count:

    select
      l.*
      ,COUNT(CASE WHEN c.type = 'cs' then 1 END) as cscount
      ,COUNT(CASE WHEN c.type = 'ls' then 1 END) as lscount
      ,COUNT(CASE WHEN c.type = 'vs' then 1 END) as vscount
    from l
    left outer join c on c.mID = l.mID
    where l.mID = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables which I need to join. First Table: EFF_DATE RATE CURRENCY
I have created two tables & inserted values as shown below . Table 1
I've two master tables Org & Item and then there's an OrgItem table.I have
I have a problem :( I have a many-many table between two tables(1&2), via
I have two tables User & User Log . User log table basically logs
I have a complex LINQ to SQL to query, which joins onto two tables
I have two tables, let's just call them A & B, which can be
I have two relational tables: the Profiles table which contains 3 kinds of user
I have 2 tables which share a common table of types The type table
I have three tables like this: Table 1 structure: Name: registered_applicant_details Fields: applicant_id INT

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.