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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:00:45+00:00 2026-06-12T22:00:45+00:00

I am trying to join these statements: select min(len(Password)) as min, max(len(Password)) as max,

  • 0

I am trying to join these statements:

select min(len(Password)) as min, 
       max(len(Password)) as max, 
       avg(len(Password)) as avg 
FROM Customer.dbo.Password 

UNION ALL
select min(len(password2)) as min, 
       max(len(password2)) as max, 
       avg(len(password2)) as avg 
FROM website.dbo.password2

To these:

SELECT c.name COLLATE SQL_Latin1_General_CP1_CI_AS colName, o.name COLLATE SQL_Latin1_General_CP1_CI_AS tableName, 'website' db FROM website.sys.all_columns as c INNER JOIN website.sys.all_objects o ON c.object_id = o.object_id WHERE c.name like '%password%' AND type = 'U'

UNION
SELECT c.name COLLATE SQL_Latin1_General_CP1_CI_AS colName, o.name COLLATE SQL_Latin1_General_CP1_CI_AS tableName, 'Customer' db FROM Customer.sys.all_columns as c INNER JOIN Customer.sys.all_objects o ON c.object_id = o.object_id WHERE c.name like '%password%' AND type = 'U' 

They have no columns in common. The first two SELECT statements produce three columns of the min, max and avg of password length and second two produce colName, tableName and db name of where the password is held.

I’d like to display both result sets in one table purely for visual reasons, to get the corresponding the min, max, avg to the appropriate colName, tableName and db.

I tried doing it this way:

DECLARE @numberTable TABLE (link nvarchar(500), max int, min int, avg int)
INSERT INTO @numberTable

select 'link', min(len(Password)) as min, 
       max(len(Password)) as max, 
       avg(len(Password)) as avg 
FROM Customer.dbo.Password UNION ALL
select 'link', min(len(password2)) as min, 
       max(len(password2)) as max, 
       avg(len(password2)) as avg 
FROM website.dbo.password2

SELECT * FROM @numberTable ORDER BY max

DECLARE @myTable TABLE (link nvarchar(500), colName nvarchar(500), tableName   nvarchar(500), db nvarchar(500))
INSERT INTO @myTable

SELECT 'link', c.name COLLATE SQL_Latin1_General_CP1_CI_AS colName, o.name COLLATE SQL_Latin1_General_CP1_CI_AS tableName, 'website' db FROM website.sys.all_columns as c INNER JOIN website.sys.all_objects o ON c.object_id = o.object_id WHERE c.name like '%password%' AND type = 'U' UNION

SELECT 'link', c.name COLLATE SQL_Latin1_General_CP1_CI_AS colName, o.name COLLATE SQL_Latin1_General_CP1_CI_AS tableName, 'Customer' db FROM Customer.sys.all_columns as c INNER JOIN Customer.sys.all_objects o ON c.object_id = o.object_id WHERE c.name like '%password%' AND type = 'U' 

SELECT * FROM @myTable ORDER BY db

SELECT link
FROM @myTable
LEFT OUTER JOIN @numberTable
ON @myTable.link = @numberTable.link

Unfortunately this didn’t work.

I’m using Microsoft SQL Server 2008.

Hope what I’m after makes sense.

  • 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-12T22:00:46+00:00Added an answer on June 12, 2026 at 10:00 pm

    You can use cross join to join two unrelated tables:

    SELECT  c.name COLLATE SQL_Latin1_General_CP1_CI_AS colName
    ,       o.name COLLATE SQL_Latin1_General_CP1_CI_AS tableName
    ,       'website' db 
    ,       pwd.[min]
    ,       pwd.[max]
    ,       pwd.[avg]
    FROM    website.sys.all_columns as c 
    INNER JOIN 
            website.sys.all_objects o 
    ON      c.object_id = o.object_id 
    CROSS JOIN
            (
            select min(len(Password)) as min, 
                   max(len(Password)) as max, 
                   avg(len(Password)) as avg 
            FROM   website.dbo.Password        
            ) as pwd
    WHERE   c.name like '%password%' 
            AND type = 'U' 
    
    UNION
    
    SELECT  c.name COLLATE SQL_Latin1_General_CP1_CI_AS colName
    ,       o.name COLLATE SQL_Latin1_General_CP1_CI_AS tableName
    ,       'Customer' db 
    ,       pwd.[min]
    ,       pwd.[max]
    ,       pwd.[avg]
    FROM    Customer.sys.all_columns as c 
    INNER JOIN 
            Customer.sys.all_objects o 
    ON      c.object_id = o.object_id 
    CROSS JOIN
            (
            select min(len(Password)) as min, 
                   max(len(Password)) as max, 
                   avg(len(Password)) as avg 
            FROM    Customer.dbo.Password        
            ) as pwd
    WHERE   c.name like '%password%' 
            AND type = 'U'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do all of these SELECT statements in all one query
Im trying to JOIN 2 tables and count the results. I have these tables;
I'm trying to join a query results on a field, 'min' - which is
I am trying to join 3 table in LINQ. var fromCities = from c
Is it possible to join the results of 2 sql SELECT statements in one
i am trying to select information from my mysql database with this statement after
I am trying to build the following SQL statement: SELECT `users_table`.*, `users_data`.`first_name`, `users_data`.`last_name` FROM
I am trying to join 3 tables to access data from each table. The
I'm trying to join 2 sql queries in one query. The first one gets
I am trying to join my users table with another table using the following

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.