| Author |
Topic |
|
adeline
Starting Member
7 Posts |
Posted - 2006-04-12 : 10:44:46
|
| is there a minus function for sql query?sum(table1) - sum(table2) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-12 : 10:49:18
|
| What do you mean by sum(table1) - sum(table2)?Give more detailsMadhivananFailing to plan is Planning to fail |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2006-04-12 : 11:15:21
|
Sure: select (select sum(...) from table1)-(select sum(...) from table2) |
 |
|
|
adeline
Starting Member
7 Posts |
Posted - 2006-04-12 : 11:45:36
|
| i mean, calculate the table1(total) and minus it from table2(total). |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-12 : 11:55:16
|
| Use the method suggested by mmarovic, or post some sample and expected dataMadhivananFailing to plan is Planning to fail |
 |
|
|
adeline
Starting Member
7 Posts |
Posted - 2006-04-12 : 11:55:20
|
| got error for tht query .... :( |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-12 : 11:56:53
|
quote: Originally posted by adeline got error for tht query .... :(
What is the error?Post the query you usedMadhivananFailing to plan is Planning to fail |
 |
|
|
adeline
Starting Member
7 Posts |
Posted - 2006-04-12 : 11:57:01
|
| select ( select sum(inc_amo) from inc)-(select sum(nec_amo) from nec) |
 |
|
|
adeline
Starting Member
7 Posts |
Posted - 2006-04-12 : 11:59:17
|
| im using a pocket pc emulator, so i cant copy and paste the error. but it is written: error in command |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-04-12 : 17:44:36
|
This is syntax is not supported in SQL CE. You have to do it in 3 steps using your applicationStep 1 : find the sum of table1Step 2 : find the sum of table2Setp 3 : subtract it KH |
 |
|
|
adeline
Starting Member
7 Posts |
Posted - 2006-04-13 : 02:32:27
|
| how to use the subtract ? i can find the total for sum1 and sum2.'Create a connection to the new database Dim ssceconn As New SqlCeConnection("Data Source = \My Documents\ppc.sdf") 'Initialize DataSet dstotaln = New DataSet dstotali = New DataSet 'data adaptor that will fills the dataset datotaln = New SqlCeDataAdapter("select sum(nec_amo)AS totaln from nec ", ssceconn) datotali = New SqlCeDataAdapter("select sum(inc_amo)AS totali from inc ", ssceconn) 'fills dataset with only results from string datotaln.Fill(dstotaln, "nec") datotali.Fill(dstotali, "inc") textBalance.DataBindings.Add("Text", dstotaln.Tables("nec"), "totaln") TextBox1.DataBindings.Add("Text", dstotaln.Tables("nec"), "totaln") TextBox2.DataBindings.Add("Text", dstotali.Tables("inc"), "totali") |
 |
|
|
|