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
 Creating New Fields Based on Several Calculations

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-17 : 08:13:49
writes "Hi,

I am VERY new to SQL and I do not know if I am word this question correctly, so forgive me.

I would like to create a new table that does calculations on some of the same fields.
• IPA number (from the IPA_Num field)
• Total number of Rx's (sum of rx field )
• Total Paid( sum of amt_paid field)
• Total generic paid (If the field drugs = 1 then sum the amt_paid field)
• Percent generic (If the field drugs = 1 then sum and divide by the sum of the field rx)
• Percent formulary (if the formulary field = A then sum and divide by the rx field)
• Cost difference ( Average amount paid per brand Rx - average amount paid per generic Rx )

Any help is greatly appreciated.

Blessing to all

Yvonne"

Kristen
Test

22859 Posts

Posted - 2005-08-17 : 08:29:29
Hi Yvonne, welcome to SQL Team!

Do you need to create a new table to hold this information, or can you just calculate it whenever you need it?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-17 : 09:07:35
I think he needs View
Create view based on these calculations and do query that view whenever you want to have calculated data

Post the table stucture

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-08-17 : 09:30:51
Madhivanan....slow down (please)

1. "I think he needs view"
nothing in the Yvonne's message indicates this need....you are jumping the gun.
Kristen's response is the most appropriate for the moment...ie everybody needs more detail from Yvonne before ANY USEFUL answer can be given. Your statement doesn't inquire as to what this information may be used for, which may indicate the appropriateness of a view or not.

Inaccurate advice may at times be worse than no advice.


2. As an FYI...."Yvonne" is a "She".....it's a female name in the English speaking world.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-17 : 09:37:13
AndrewMurphy,

The questioner asked "I would like to create a new table that does calculations on some of the same fields"

So I assumed that it can be done with View

>>Inaccurate advice may at times be worse than no advice.

Thats True. I agree

>>As an FYI...."Yvonne" is a "She".....it's a female name in the English speaking world.

I didnot know that


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-08-17 : 12:04:59
"I didnot know that"

Madhivanan


That's o.k....just as I obviously can't figure you out from your name either!
Go to Top of Page
   

- Advertisement -