Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write in SQL server, Type the query below in a query window and run to see 2 table results IF OBJECT_ID('tempdb..#DestinationNetWorth') IS NOT NULL DROP

write in SQL server,

Type the query below in a query window and run to see 2 table results

IF OBJECT_ID('tempdb..#DestinationNetWorth') IS NOT NULL

DROP TABLE #DestinationNetWorth;

SELECT *

INTO #DestinationNetWorth

FROM

(

VALUES

(0, 25000),

(25001, 50000),

(50001, 200000),

(200001, 500000),

(500001, 1000000),

(1000001, 3000000),

(3000001, 100000000)

) AS a (MinRange, MaxRange);

IF OBJECT_ID('tempdb..#SourceNetworth') IS NOT NULL

DROP TABLE #SourceNetworth;

SELECT *

INTO #SourceNetworth

FROM

(

VALUES

('$25,000 and under'),

('$1,000,001 - $3,000,000'),

('$200,001 - $500,000'),

('$25000 - $50000'),

('$500,001 - $1,000,000'),

('$50,001 - $200,000'),

('$50,001-200,000'),

('$9,001-35,000')

) AS b (NetWorth);

SELECT * FROM #SourceNetworth

SELECT * FROM #DestinationNetWorth

Now write a select Query to get the results as below screenshot

NetWorth DestMin DestMax

----------------------- ----------- -----------

$25,000 and under 0 25000

$9,001-35,000 0 25000

$25000 - $50000 25001 50000

$50,001 - $200,000 50001 200000

$200,001 - $500,000 200001 500000

$500,001 - $1,000,000 500001 1000000

$1,000,001 - $3,000,000 1000001 3000000

Tips and Tricks

You need to join this table with the maximum overlapped range i.e if the expected ranges are 0-15;15- 30 and the given range is 10-25 you need to pick 15-30 as that is the maximum overlapped range

Youll may also need to do a lot of cast and converts to get it in the integer formats to compare the ranges

This can all be done in a single sql select statement if possible (recommend not to use Temp Tables)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

How is the compensation for sales representatives determined?

Answered: 1 week ago