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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Selecting groups of rows in a table.. argh!

Author  Topic 

marci
Starting Member

2 Posts

Posted - 2014-02-06 : 11:16:50
Table 1:
A B C
1 1 4.7
2 1 4.7
3 1 4.7

Table 2:
A D E
1 1a 1.2
1 1b 1.8
2 2a 2.1
2 2b 2.3
3 3a 0.6


I would like to filter the second table taking one row per ID of Field A (first table) and selecting the rows whose sum of E is equal to the value in field C; in this example the resulting table should be:

Table 3:
A D E
1 1b 1.8
2 2b 2.3
3 3a 0.6

Total field E = value in field C = 4.7

Thanks a lot in advance!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-10 : 09:04:26
Will A values always be continuos?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

marci
Starting Member

2 Posts

Posted - 2014-02-11 : 03:52:27
new suggestions here: http://www.sqlservercentral.com/Forums/Topic1538729-1292-2.aspx?Update=1

Thanks visakh16!
Go to Top of Page
   

- Advertisement -