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 |
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2014-02-28 : 23:57:58
|
In this table:select * into #tmpfrom(select 'abc' a, 'xyz' b, 10 c union allselect 'abc' a, 'ghi' b, 20 c union allselect 'abc' a, 'aaa' b, 30 c ) tHow can you group it by column a, b take max(c), BUT exclude rows with b='aaa'??So that the result is 20.Thanks--PhB |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-03-01 : 00:05:10
|
[code]select max(c)from #tmpwhere b <> 'aaa'[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
phrankbooth
Posting Yak Master
162 Posts |
Posted - 2014-03-01 : 00:21:12
|
thanks for your reply.sorry, I should have been clearer.I simplified the table, but I talked about grouping it because 'aaa' is not the only field value, there will be more rows with other groupings besides 'abc'--PhB |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-03-01 : 00:31:22
|
then can you illustrate further on your requirement ? KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|