| Author |
Topic |
|
feejaz
Yak Posting Veteran
68 Posts |
Posted - 2007-12-11 : 08:57:28
|
| hi folks...now m in serious trouble...i hve a very complicated problem now...let me explaini have a table in SQL...I have to select values from this table depending on 2 where conditions.....and add these values......and insert them in another table......now can somebody tell me how can i add the values from the database and store them in a session and update them to another table...if i am not clear then ask me i will explain u in more detailNavi |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-11 : 08:59:34
|
| I am confused? do you want to insert new record in another table with added value or update table with new value?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 09:10:13
|
INSERT TargetTable (Col1)SELECT ColA + ColBFROM SourceTableWHERE ColBlue = 'SQLTeam' AND ColGreen = 'Peso' E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-11 : 09:14:32
|
quote: Originally posted by Peso INSERT TargetTable (Col1)SELECT ColA + ColBFROM SourceTableWHERE ColBlue = 'SQLTeam' AND ColGreen = 'Peso' E 12°55'05.25"N 56°04'39.16"
OP, Beware of NULLMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-11 : 09:17:14
|
Me? I think you need to tell OP that.He didn't provide enough information. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-11 : 09:19:43
|
quote: Originally posted by Peso Me? I think you need to tell OP that.He didn't provide enough information. E 12°55'05.25"N 56°04'39.16"
Its to OP. I edited my reply MadhivananFailing to plan is Planning to fail |
 |
|
|
feejaz
Yak Posting Veteran
68 Posts |
Posted - 2007-12-12 : 04:54:28
|
| i dont have to add the clumns. i have to add the rows....wat do i do?Navi |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-12 : 05:51:44
|
No idea what you are talking about.Can you post some proper and accurate sample data together with your expected result? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-12 : 07:03:52
|
| Use aggregate functions like SUM() to add up row values.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-12-12 : 09:41:02
|
could have swornd that SUM() added up column values....  SUMReturns the sum of all the values, or only the DISTINCT values, in the expression. SUM can be used with numeric columns only. Null values are ignored. [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
feejaz
Yak Posting Veteran
68 Posts |
Posted - 2007-12-15 : 07:53:36
|
| i have a table in the below shown formatValues Items.......................................................TABLE1Customer1 20 Fuses Customer2 30 Screws Customer3 40 Fuses Customer1 45 Fuses Customer3 78 BatteriesCustomer1 40 Screwsnow i want to add the values of screw of customer1 and insert in a table in one field as shown belowScrews Fuses Screws .................................TABLE2there is the example of my questionCustomer1 65 (total of above) 115 40 Custoerm2 ------------------------------------NOW ADD VALUES IN THE ABOVE WAY AND INSERT IN THE TABLE 2Navi |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-15 : 09:12:09
|
| Read about Cross-tab reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|