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.
| Author |
Topic |
|
duf
Starting Member
39 Posts |
Posted - 2012-07-05 : 03:25:47
|
| Is it possible to execute a single query with many conditions OR?SELECT SUM(WARTOSC) FROM WARTPLN WHERE FV=1 OR FV=2 ... etcValues for a column FV i get from this query:SELECT ID FROM FVNAGIn the latter query, there are many records and i can not connect to the first query. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-07-05 : 03:29:57
|
This?SELECT SUM(WARTOSC) FROM WARTPLN WHERE FV in (SELECT ID FROM FVNAG) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
duf
Starting Member
39 Posts |
Posted - 2012-07-05 : 03:39:35
|
| Thank You |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-05 : 09:55:17
|
you can use exists alsoSELECT SUM(WARTOSC) FROM WARTPLN w WHERE EXISTS (SELECT 1 FROM FVNAG WHERE ID = w.FV) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-07-05 : 10:36:26
|
well yeah. You could do those things... Or you could JOIN it.SELECT SUM(w.[WARTOSC]) AS [SumWar]FROM WARTPLN AS w JOIN FVNAG AS ON f.[ID] = w.[FV] Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-05 : 10:46:34
|
quote: Originally posted by Transact Charlie well yeah. You could do those things... Or you could JOIN it.SELECT SUM(w.[WARTOSC]) AS [SumWar]FROM WARTPLN AS w JOIN FVNAG AS ON f.[ID] = w.[FV] Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
so long as relationship is one to one------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-07-05 : 11:18:10
|
| Very True.I concede the point.Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. |
 |
|
|
|
|
|