SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Multi Level Lookup
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

IgnDsouza
Starting Member

India
6 Posts

Posted - 04/24/2012 :  11:50:01  Show Profile  Reply with Quote
Hi,

I hope someone could help me. I've been working on this a long time & have not got the desired result.

I am trying to get a compatibility done with Add-On's active on a particular account.

I have one query which gives me the Add-On's active on a particular account along with the Price Plan for that account.

Account# Price Plan Add-On
999999 Talk 900 SMS 150
999999 Talk 900 MMS 250
999999 Talk 900 Int 150
999999 Talk 900 Internet
999999 Talk 900 Skype

The Account# & the Price Plan remains the same for an account whereas the Add-On differs & hence the multiple entries for the same account.

I have another table which I have created on a different database which gives me the compatibility matrix of the Price Plans with the Add-On's


Price Plan Add-On
Talk 900 SMS 150
Talk 900 MMS 250
Talk 900 Int 150
Talk 900 Internet
Video 100 MMS 250
Video 100 Int 150
Video 100 Internet
Video 100 Skype
Video Talk 300 SMS 150
Video Talk 300 MMS 250
Video Talk 300 Int 150
Video Talk 300 Internet
Video Talk 300 Skype

I know how to join two databases on SQL Server; however, I am unable to get the compatibility done on the 1st query.

The result I require is to run the 1st Query, Look-up with the compatibility matrix & return a column TRUE or FALSE.

I Hope someone can help me. Thanks in advance

Ignatius D'souza
Revenue Assurance & Billing - Ireland
M: +91-99677 14397
E: Ignatius.Dsouza2@3globalservices.com
MSN: dsouza.ignatius@hotmail.com

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 04/24/2012 :  21:50:22  Show Profile  Reply with Quote
so what should be output for the above dataset?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

IgnDsouza
Starting Member

India
6 Posts

Posted - 04/25/2012 :  04:32:42  Show Profile  Reply with Quote
The output for the query should give the results of the 1st query along with another column stating whether TRUE or FALSE as compared to the compatibility matrix.

The output should look something like below
Account# Price Plan Add-On Condition
999999 Talk 900 SMS 150 TRUE
999999 Talk 900 MMS 250 TRUE
999999 Talk 900 Int 150 FALSE
999999 Talk 900 Internet FALSE
999999 Talk 900 Skype TRUE


Ignatius D'souza
Revenue Assurance & Billing - Ireland
M: +91-99677 14397
E: Ignatius.Dsouza2@3globalservices.com
MSN: dsouza.ignatius@hotmail.com
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16745 Posts

Posted - 04/25/2012 :  04:39:10  Show Profile  Reply with Quote
why is these 2 FALSE
- 999999 Talk 900 Int 150 FALSE
- 999999 Talk 900 Internet FALSE

and this TRUE ?
- 999999 Talk 900 Skype TRUE


KH
Time is always against us

Go to Top of Page

IgnDsouza
Starting Member

India
6 Posts

Posted - 04/25/2012 :  07:12:34  Show Profile  Reply with Quote
It's just an example that I have used.

The 1st query looks up the compatibility table & it a Particular add-on does not match the Price Plan on the matrix, it should return the value FALSE else TRUE

Ignatius D'souza
Revenue Assurance & Billing - Ireland
M: +91-99677 14397
E: Ignatius.Dsouza2@3globalservices.com
MSN: dsouza.ignatius@hotmail.com
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16745 Posts

Posted - 04/25/2012 :  07:15:46  Show Profile  Reply with Quote
So does the required result that you posted reflect the business logic that you required ? Or is it just a random example ?


KH
Time is always against us

Go to Top of Page

IgnDsouza
Starting Member

India
6 Posts

Posted - 04/25/2012 :  08:10:16  Show Profile  Reply with Quote
Yes this is the required Business logic for the query.
But the data given is only for illustration purpose

Ignatius D'souza
Revenue Assurance & Billing - Ireland
M: +91-99677 14397
E: Ignatius.Dsouza2@3globalservices.com
MSN: dsouza.ignatius@hotmail.com
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16745 Posts

Posted - 04/25/2012 :  08:11:52  Show Profile  Reply with Quote
then can you post the expected result that correspond to the sample data that you have posted ?


KH
Time is always against us

Go to Top of Page

IgnDsouza
Starting Member

India
6 Posts

Posted - 04/25/2012 :  09:05:10  Show Profile  Reply with Quote
The expected output is as below.


Account # Price Plan Add-On Condition
12345 Talk 900 SMS 150 TRUE
12345 Talk 900 SMS 250 TRUE
12345 Talk 900 Internet FALSE
23125 Video 100 SMS 150 TRUE
23125 Video 100 SMS 250 TRUE
23125 Video 100 Internet FALSE
31254 VideoTalk300 Internet TRUE

The places where the condition shows FALSE is when the combination of Price Plan or Add-on is not present in the compatibility matrix.

Ignatius D'souza
Revenue Assurance & Billing - Ireland
M: +91-99677 14397
E: Ignatius.Dsouza2@3globalservices.com
MSN: dsouza.ignatius@hotmail.com
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16745 Posts

Posted - 04/25/2012 :  10:15:55  Show Profile  Reply with Quote

SELECT . . .
Condition = case when exists ( select * from matrix x 
                                   where x.PricePlan = a.PricePlan 
                                   and   x.AddOn     = a.AddOn )
                 then 'TRUE'
                 else 'FALSE'
                 end
FROM  account a



KH
Time is always against us

Go to Top of Page

IgnDsouza
Starting Member

India
6 Posts

Posted - 04/25/2012 :  11:08:34  Show Profile  Reply with Quote
Hey,

Thanks for you help. The query now works & gives me the desired output.

Thanks a ton

Ignatius D'souza
Revenue Assurance & Billing - Ireland
M: +91-99677 14397
E: Ignatius.Dsouza2@3globalservices.com
MSN: dsouza.ignatius@hotmail.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000