| Author |
Topic |
|
swathigardas
Posting Yak Master
149 Posts |
Posted - 2007-09-12 : 06:57:57
|
| Hi all. I’ve been visiting this forum... But this is my first time posting a question.I’m using Sql 2005 as database.Let me explain you the problemThere are tables like Price_table_10, Price_table_15, Price_Table_63, Price_Table_100, Price_Table_250Same column Format is Present in all the TablesTable for Price_table_for_10 looks like theseVolt Guarntee_year Price Tax Total Price10 0 12000 10 1 13000 10 2 24777 10 3 5688 10 4 89000 10 5 43567 10 6 7889 10 7 8754 10 8 9024 Now the same format is applied all the tables.Tax is updated based on the Guarantee YearFor the Guarantee Year 0The query isUpdate Price_table_10 set tax=price*(11/100) where Guarantee Year=0So its different for all the Guarantee YearsThe percentage used for tax calculation is different for different Price tablesI want to update all these Price tables in a if loop.The loop should be something likeIf Price_table_10Then update Price_table_10 set tax = price*(11/100) where Guarantee Year=0If Price_table_15 then update Price_table_25 set tax=price*(13/100) where Guarantee Year=0If Price_table_25 then update Price_table_15 set tax=price*(15/100) where Guarantee Year=0 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-09-12 : 06:59:20
|
| Instant solution: Read my signature, follow the LEARN SQL links. Problem solved.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-09-12 : 07:07:13
|
use dsql to pull this off, passing the table namecheck out cursor or while loop also, you should really have your application handle this update when the record gets inserted... makes life easier --------------------keeping it simple... |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-12 : 07:43:05
|
One thing not mentioned in those links are INTEGER DIVISION.11 / 100 equal 0!Write 11 / 100.0 instead. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-09-12 : 10:21:54
|
what's the matter Peso? do you like paying tax?  elsasoft.org |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-12 : 11:02:43
|
Hehehe... No, but if you do not pay tax in Sweden, you are most likely to go to prison. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Jenda
Starting Member
29 Posts |
Posted - 2007-09-12 : 14:28:16
|
quote: Originally posted by swathigardas Hi all. I’ve been visiting this forum... But this is my first time posting a question.I’m using Sql 2005 as database.Let me explain you the problemThere are tables like cost_table_10, Cost_table_15, Cost_Table_63, Cost_Table_100, Cost_Table_250
Step 1. Shoot whoever designed the database schema.Step 2. Consolidate all Cost_Table_x into a single Cost_Table and (to localize the impact of the change) create a view in place of every Cost_Table_x.Step 3. run the query using CASE WHEN... THEN ... END to compute the tax with the right constants for each former tableStep 4. Go homeP.S.: Don't forget to get rid of the body! |
 |
|
|
wackoyacky
Starting Member
25 Posts |
Posted - 2007-09-13 : 05:25:53
|
| Just my two cents...You should have ask help in a nicer way, not like as if you're paying someone to solve your problem and what makes things worst is you want it ASAP! lolz |
 |
|
|
swathigardas
Posting Yak Master
149 Posts |
Posted - 2007-09-14 : 05:26:11
|
| Hey thanks Jendai guess i can work with the solution that you provided me.regardsswathi |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-14 : 05:44:09
|
quote: Originally posted by Peso Hehehe... No, but if you do not pay tax in Sweden, you are most likely to go to prison. E 12°55'05.25"N 56°04'39.16"
50% tax?MadhivananFailing to plan is Planning to fail |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-09-14 : 07:54:44
|
taxes in Sweden are so high, even after the integer division bug they are still non-zero.  elsasoft.org |
 |
|
|
|