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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:00:19+00:00 2026-05-24T07:00:19+00:00

I have the following code that will join two different tables together and provide

  • 0

I have the following code that will join two different tables together and provide the discrete data columns that I need. The issue is I also need a column that counts another instance from another table. See pointer reference undernearth the select statement.

  SELECT 
  //count(of records returned from below query and duplicates of those found in outc table),
  outage_duration.dgroup,
  outage_duration.cause,
  outage_duration.cdts,
  outage_duration.cust_minutes,
  outage_duration.evntnum,
  outage_duration.num_cust,
  outage_duration.outage_type,
  outage_duration.substation,
  outage_duration.feeder,
  outage_duration.out_minutes
  FROM outage_duration,
  aeven
  WHERE outage_duration.evntnum    = aeven.num_1
  AND aeven.outage_type            = 'T'
  AND aeven.cdts                  >= '20110101060000UT'
  AND aeven.curent                 = 'T'
  AND aeven.open_and_curent        = 'F'
  AND aeven.ag_id NOT             IN    ('MEMT','MTRRDR','MTRTECH','GRDLT','FSRSR','ELECOPS','AMS','REVSEC')
  AND outage_duration.out_minutes >= '240'
  AND outage_duration.curent = 'T' 
  GROUP BY outage_duration.dgroup, outage_duration.cause, outage_duration.cdts, outage_duration.cust_minutes, outage_duration.evntnum, outage_duration.num_cust, outage_duration.outage_type, outage_duration.substation, outage_duration.feeder, outage_duration.out_minutes
  ORDER BY outage_duration.evntnum

Sample AEVEN, Outage_Duration table

num_1
T344490
T344410
T344480

outage_duration
T344490
T344410

This would return T344490 and T44410 which is what the above search does. Now with these results I need to take a count from another table altogether and display the count as its own column beside the event number of how many occurences there were in that table.

outc (column 1 = unique id, column 2 = evntnum)

 1. 1, T344490
 2. 2, T344490
 3. 3, T344410
 4. 5, T344410
 5. 6, T344410
 6. 7, T344410
 7. 8, T344410

The desired results would like to be the following:

 1. T344410, 5, "other columns that were specified"
 2. T344490, 2, "other columns that were specified"

How would I manage to do this?

  • 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-24T07:00:19+00:00Added an answer on May 24, 2026 at 7:00 am
    SELECT 
      COUNT(*), --this
      outage_duration.dgroup,
      outage_duration.cause,
      outage_duration.cdts,
      outage_duration.cust_minutes,
      outage_duration.evntnum,
      outage_duration.num_cust,
      outage_duration.outage_type,
      outage_duration.substation,
      outage_duration.feeder,
      outage_duration.out_minutes
      FROM
          outage_duration
          JOIN
          aeven ON outage_duration.evntnum    = aeven.num_1
          JOIN
          outc ON outage_duration.evntnum = outc. --insert column here
      WHERE 
      AND aeven.outage_type            = 'T'
      AND aeven.cdts                  >= '20110101060000UT'
      AND aeven.curent                 = 'T'
      AND aeven.open_and_curent        = 'F'
      AND aeven.ag_id NOT             IN           ('MEMT','MTRRDR','MTRTECH','GRDLT','FSRSR','ELECOPS','AMS','REVSEC')
      AND outage_duration.out_minutes >= '240'
      AND outage_duration.curent = 'T' 
      GROUP BY outage_duration.dgroup, outage_duration.cause, outage_duration.cdts, outage_duration.cust_minutes, outage_duration.evntnum, outage_duration.num_cust, outage_duration.outage_type, outage_duration.substation, outage_duration.feeder, outage_duration.out_minutes
      ORDER BY outage_duration.evntnum
    

    Just add a COUNT(*) to the SELECT bit, and the table outc to the FROM

    You already have a GROUP BY so should just slot itn

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

Sidebar

Related Questions

I have the following code that is working on my local machine (Win 7,
Lets say we have the following code: #include <iostream> #include <string> struct A {
I have a small problem with the following code. The code works fine if
I am trying to create a VBA code that will run through each distinct
I have a file that was encrypted using AES. I use the following NSData
I have the following classes: using System; using System.Windows.Forms; namespace FastEyeControl { public partial
I have a program that is opening an explorer window to a certain folder
I'm using a COM object from a third party library that generates periodic events.
I'm pretty much new at WCF and have a performance question. I have the
There is a timer which sends out signal SIGALARM every 1 sec. A signal

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.