Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert statement

Author  Topic 

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-11-19 : 13:25:43

Can someone help me understand this query, specifically I want to change the ending where statement to multiple fields that make 10000,10001 and 10002 unique to that specific programid. but still not sure what this statement is doing.

Thanks again!

GG

INSERT INTO [Rating_2].[dbo].[RateData]
([ApplicationID]
,[ProgramID]
,[CoverageID]
,[LimitCoverageID]
,[LimitMin]
,[LimitMax]
,[RateCalcCoverageID]
,[Rate]
,[CalcType]
,[RateType]
,[EffectiveDate]
,[ExpirationDate]
,[PCMin]
,[PCMax]
,[Territory])
(select 3, programid, 1 covid, 1 limitcovid, limitmin, limitmax, 1, m1 , 'F', 'B', '11/1/2009', '12/31/2999', 1, 6, 'A'
from ratesa r
inner join programs p on 1=1
where p.programid in (10000,10001,10002))

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-19 : 13:29:10
It's just inserting the rows where it matches that programid. By the way, the yellow is impossible to read. I had to highlight it to read it.

Please show us a data example of what you want it to do as I'm unclear what this means: multiple fields that make 10000,10001 and 10002 unique to that specific programid.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-11-19 : 15:31:22
Sorry about the yellow!ha I thought it was going to highlight. Below is the table I am trying to insert value into table ratedata.I want to insert the rate from the table below when the variables to the rate match all the variables in associated with the programid. Here is the table....and then below that are various fields in tables. thanks for the help.

Territory A; Owner
Coverage PC 1 - 6 PC 7 - 8 PC 9 - 10
min max Frame Masonry Frame Masonry Frame Masonry
min Max f1 m1 f6 m6 f9 m9
1000 1000 1181 1064 1181 1064 1181 1064
1001 2000 1200 1081 1200 1081 1200 1081
2001 3000 1218 1097 1218 1097 1218 1097
3001 4000 1235 1113 1235 1113 1235 1113
4001 5000 1254 1130 1254 1130 1254 1130
5001 6000 1272 1146 1272 1146 1272 1146
6001 7000 1291 1163 1291 1163 1291 1163
7001 8000 1309 1179 1309 1179 1309 1179
8001 9000 1328 1196 1328 1196 1328 1196
9001 10000 1345 1212 1345 1212 1345 1212


fields in table

RateID
ApplicationID
ProgramID
CoverageID
LimitCoverageID
LimitMin
LimitMax
RateCalcCoverageID
Rate
CalcType
RateType
EffectiveDate
ExpirationDate
PCMin
PCMax
Territory
State
OccupancyTypeID
PolicyType
ConstructionType
policyterm
DCmin


Let me know what else info you need? I can also email you if that would help. I really could use the help.

GG



Go to Top of Page

JJins
Yak Posting Veteran

81 Posts

Posted - 2010-11-19 : 15:37:04
first row limitmin, second row limitmax, thirdrow f1 fourth m1 fifth f6 sixth m6 seventh f9, eighth m9


above that is PC 1-6 is for f1 and m1

PC 6-8 F6 note above should be pc 6-8 not 7-8.
pc 9-10 f9
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-11-19 : 15:51:10
Maybe I have food coma.. but I'm not understanding your sample data. Maybe this link will help your perpare your question a little better:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-19 : 16:56:17
I'm not understanding it either.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -