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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:35:59+00:00 2026-06-12T20:35:59+00:00

I have below two tables which i need to combine together into my daily

  • 0

I have below two tables which i need to combine together into my daily reports.

Table 1: Resource_Created

FirstName LastName ObjDate Resource Login

TestDemo1        TestDemo1       5-Oct-12         AD         TESTDEMO1

Table 2: Resource_Deleted

FirstName LastName ObjDate Resource Login

TestDemo4        TestDemo4       5-Oct-12         AD         TESTDEMO4

TestDemo5        TestDemo5       5-Oct-12         AD         TESTDEMO5

TestDemo6        TestDemo6       5-Oct-12         AD         TESTDEMO6

TestDemo4        TestDemo4       5-Oct-12         Bio        TESTDEMO4

TestDemo4        TestDemo4       5-Oct-12         VPN        TESTDEMO4

TestDemo5        TestDemo5       5-Oct-12         VPN        TESTDEMO5

TestDemo6        TestDemo6       5-Oct-12         VPN          TESTDEMO6

I wrote two queries individually like

Query 1:

select distinct Resource as Resource, 
       count (distinct Login) as CountRes 
from Resource_Created 
where ObjDate between '4-Oct-12' and '6-Oct-12' 
group by Resource ;

Result:

Resource CountRes

 AD        1

Query 2:

select distinct Resource as Resource, 
       count (distinct Login) as CountRes 
from Resource_Deleted 
where ObjDate between '4-Oct-12' and '6-Oct-12' 
group by Resource ;

Result

Resource CountRes

AD          3

VPN         3

Bio         1

I wish to combine these two queries, so that i can have one table display these values.

select COALESCE (Resource_Created.Resource, Resource_Deleted.Resource) as Resource , 
 count (distinct Resource_Created.usrlogin) as aobj, 
 count (distinct Resource_Deleted.usrlogin) as bobj
FROM target_failed  FULL OUTER JOIN target_resource  
 on Resource_Created.Resource = Resource_Deleted.Resource 
where
 Resource_Created.ObjDate between '04-OCT-2012' and '06-OCT-2012' and 
 Resource_Deleted.ObjDate between '04-OCT-2012' and '06-OCT-2012'
group by COALESCE(Resource_Created.Resource, Resource_Deleted.Resource);

My Result was

**Resource       aobj         bobj**

   AD         1                3

Expected Result

Resource aobj bobj

 AD             1          3

VPN           Null         3

Bio           Null         1

Please could anyone help me resolve the issue. I am just a OO developer who writes basic sql queries. It would be greatly appreciated.

  • 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-12T20:36:00+00:00Added an answer on June 12, 2026 at 8:36 pm

    Simply use sub sql on from statement

    select 
      ResourceI as rs, sum (CreatedLogin) as CountCreated,
     sum (DeletedLogin) as CountDeleted
    from 
    (select 
     ObjDate,
     Resource ,
     1 as DeletedLogin,
     0 as CreatedLogin 
     from  Resource_Deleted
     union all
     select ObjDate,
     Resource ,
     0 as DeletedLogin,
     1 as CreatedLogin  
     from  Resource_Created
    )  TABLE_ALL
    where ObjDate between TO_DATE('4-Oct-12') and TO_DATE('6-Oct-12')
    group by Resource
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, REPORTS and REPORT_TYPE which are as described below. REPORTS REPORT_TYPE_ID
I have two table masterTbl and detailTbl which structure is given below... --PRIMARY TABLE
I have two tables described below. What I need is a single query that
I have two tables like the ones below. I need to find what exchangeRate
I have created two tables & inserted values as shown below . Table 1
OK I have two sql tables I need to query from which are product
I have two similar tables which have data I need to display in a
I have written below stored procedure. In which i need to create Two Temporary
I have two tables names book_list and book_category . Schema is like below: book_list
I'm using SQL Server 2008. Let's say I have two hypothetical tables like below:

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.