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
 General SQL Server Forums
 New to SQL Server Programming
 perform calculation on responsnse from a form
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

parry02
Starting Member

United Kingdom
18 Posts

Posted - 08/02/2006 :  05:41:30  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
1907 Posts

Posted - 08/02/2006 :  05:46:41  Show Profile  Visit chiragkhabaria's Homepage  Send chiragkhabaria a Yahoo! Message  Reply with Quote
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

United Kingdom
18 Posts

Posted - 08/02/2006 :  05:54:46  Show Profile  Reply with Quote
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

Sweden
30282 Posts

Posted - 08/02/2006 :  05:55:24  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

Edited by - SwePeso on 08/02/2006 05:56:25
Go to Top of Page

parry02
Starting Member

United Kingdom
18 Posts

Posted - 08/02/2006 :  06:50:28  Show Profile  Reply with Quote
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

Sweden
30282 Posts

Posted - 08/02/2006 :  06:56:28  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

Peter Larsson
Helsingborg, Sweden

Edited by - SwePeso on 08/02/2006 06:57:28
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.06 seconds. Powered By: Snitz Forums 2000