| Author |
Topic |
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2011-03-31 : 13:29:10
|
| How can I inner join these select statements to make this view work?create view [NJ.HO6.Lloyds]as SELECT distinct rate*100 [<1 mile from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'A'and programs.policytype = 2 and programs.DCmax = 1 and ratedata.PCmax < 9 and programs.constructiontype != 3 SELECT distinct rate*100 [1-5 miles from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'A'and programs.policytype = 2 and programs.DCmax = 5 and ratedata.PCmax < 9 and programs.constructiontype != 3 SELECT distinct rate*100 [>5 miles from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'A'and programs.policytype = 2 and programs.DCmax = 9999 and ratedata.PCmax < 9 and programs.constructiontype != 3---Group BSELECT distinct rate*100 [All milage]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'B'and programs.policytype = 2 and ratedata.PCmax < 9 and programs.constructiontype != 3---Group CSELECT distinct rate*100 [All milage]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'C'and programs.policytype = 2 and ratedata.PCmax < 9 and programs.constructiontype != 3---Group DSELECT distinct rate*100 [<1 mile from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'D'and programs.policytype = 2 and programs.DCmax = 1 and ratedata.PCmax < 9 and programs.constructiontype != 3SELECT distinct rate*100 [1-5 miles from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'D'and programs.policytype = 2 and programs.DCmax = 5 and ratedata.PCmax < 9 and programs.constructiontype != 3 SELECT distinct rate*100 [>5 miles from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'D'and programs.policytype = 2 and programs.DCmax = 9999 and ratedata.PCmax < 9 and programs.constructiontype != 3 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2011-03-31 : 13:48:28
|
| that is great thank you. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2011-03-31 : 13:58:37
|
| The only problem is when I us UNION it removes the header.....that I need when I export to excel...............how do I keep the header? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2011-03-31 : 14:07:21
|
| I am creating a view then exporting that view into excel. What I need to show up is [>5 miles from coast],[1-5 miles from coast],[>5 miles from coast] above each out put. let me know if that makes sense. Thanks for your help. the union is bluring them all together under the same header.create view [**********]as SELECT distinct rate*100 [<1 mile from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'A'and programs.policytype = 2 and programs.DCmax = 1 and ratedata.PCmax < 9 and programs.constructiontype != 3union SELECT distinct rate*100 [1-5 miles from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'A'and programs.policytype = 2 and programs.DCmax = 5 and ratedata.PCmax < 9 and programs.constructiontype != 3union SELECT distinct rate*100 [>5 miles from coast]FROM RateData INNER JOIN Programs ON RateData.ProgramID = Programs.ProgramIDwhere programs.state = 'NJ' and programs.companyid = 4 and ratedata.coverageid <5 and Ratedata.territory = 'A'and programs.policytype = 2 and programs.DCmax = 9999 and ratedata.PCmax < 9 and programs.constructiontype != 3 |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2011-03-31 : 14:13:13
|
| can you give me an example with the data I sent.......not exacly sure how to follow.Thanks. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|