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
 perform calculation on responsnse from a form

Author  Topic 

parry02
Starting Member

18 Posts

Posted - 2006-08-02 : 05:41:30
i have a form where I ask a number of questions
The answer for each question is a drop down menu ...
The person chooses one or many from the answer ....

e.g I would like a wrist band for Trip A (cost £6) {WristA}
I would like a wrist band for Trip B (cost £8) {WristB}
I would like wrist band for Trip C (cost £4) {WristC}

etc etc ....
I would like to grab thes responses from the form
and write SQL script to perform the total cost of wristbands...

Any ideas on how I can do this in SQL - the 'tokens' are available in SQL (i.e. {WristA} , {WristB}, {WristC})

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-02 : 05:46:41
In which Table you are saving the records of the cost to the corresponding item,
if you can post that then some one over here can help you to write down your query

Chirag
Go to Top of Page

parry02
Starting Member

18 Posts

Posted - 2006-08-02 : 05:54:46
I am saving it in a table called 'TripTable'
I would like to grab the responses (selected on the form)
and total up th cost and put it in a column 'TotalCost'
and each response put it in column 'WristA' 'WristB' and 'WristC'....
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-02 : 05:55:24
Something like

select sum(mpt.price) as totalprice
from mypricetable mpt
inner join dbo.fnAnySplitStringFunction('wrist a;wrist b;wrist c', ';') sf on sf.part = mpt.wrist

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

parry02
Starting Member

18 Posts

Posted - 2006-08-02 : 06:50:28
please can you explain further - as I'm acomplete idiot in SQL
e.g which are the responses from the form ???
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-02 : 06:56:28
[code]select sum(mpt.price) as totalprice -- This is the summation of all responses in form
from mypricetable mpt -- this is the table where you have the price information
inner join dbo.fnAnySplitStringFunction('wrist a;wrist b;wrist c', ';') sf on sf.part = mpt.wrist -- This the responses from the form concatenated as one string with ";" as delimiter[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -