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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:13:56+00:00 2026-06-08T10:13:56+00:00

This site has been super helpful with this database i am creating for work,

  • 0

This site has been super helpful with this database i am creating for work, i have a lot of VB knowledge but little SQL.

i am creating a database of cisco IP phones which records the MACs, serials and to what site id they are assigned to.

My managers have now decided to change the goal posts of my application once again and are now asking for me to create a form that displays data in a way i have no idea how to do.

what they now want and what i am hoping to achieve somehow is to create a sql statement that gets the count of the number handsets by site id and then to compare that number against the data from another table.

Here is the fields that we need to work with:

TABLE 1
Handset_Type
Handset_Site_Id

TABLE 2
Handset_Type
Handset_Site_Id

This is how i would like to display the data

SITE ID        | Handset_Type1      | Handset_Type1 
Handset_Site_id1 |COUNT TYPE1 FROM T1|COUNT TYPE1 FROM T2 
Handset_Site_id2 |COUNT TYPE1 FROM T1|COUNT TYPE1 FROM T2 

If we can use the data in the Handset_type field to create the column headings then that would be great as there are only a few models of phones but if they are static columns then that will be ok also.

I hope i have explained this ok as i can see this may be complex to understand.

if you have any suggestions please let me know

Thank you

Steve

  • 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-08T10:13:58+00:00Added an answer on June 8, 2026 at 10:13 am

    If I understand the question correctly, you would like to present the count of records from both tables, with the handset type and source table as column headings, for each site ID.

    The first step is to merge your tables into a single table, creating a column which expresses the handset type and source table:

    SELECT Handset_Type & " in T1" as TypeFromT, Handset_Site_Id FROM [Table 1]
    UNION ALL
    SELECT Handset_Type & " in T2" as TypeFromT, Handset_Site_Id FROM [Table 2]
    

    This will form an inner query for the crosstab. The syntax for crosstabs can be a bit tricky so I usually build mine in design view. We define the TypeFromT as our new column heading and we use Handset_Site_Id both as our row groupings and as our counting field:

    TRANSFORM Count(SubQry.Handset_Site_Id) AS SiteIDCount
    SELECT SubQry.Handset_Site_Id
    FROM (
        SELECT Handset_Type & " in T1" as TypeFromT, Handset_Site_Id FROM [Table 1]
        UNION ALL
        SELECT Handset_Type & " in T2" as TypeFromT, Handset_Site_Id FROM [Table 2]
    ) AS SubQry
    GROUP BY SubQry.Handset_Site_Id
    PIVOT SubQry.TypeFromT;
    

    The only catch is that if there are zero entries for the particular Handset Type, Source Table, and Site ID, the resulting value will be null instead of a 0. If that is undesirable, replace Count(SubQry.Handset_Site_Id) with Nz(Count(SubQry.Handset_Site_Id),0)

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

Sidebar

Related Questions

I don't think this has been asked before on this site, but I might
Everyone on this site has been very helpful on my schooling of iOS programming,
This question has been asked before ( link ) but I have slightly different
I have this classic ASP site which has been working fine until we updated
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
This has been frustrating me for a while now. I started developing a site
This site has a technique to pass xml data around in Microsoft SQL Server:
I was creating a website http://tapasya.co.in and i found that this site has some
I'm getting into SDK documentation, but this site has so many eyes and great
I have a site that has an Rss feed, and this feed is consumed

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.