我正在构建一个访问数据库,并且我正在尝试减少一个大的结果集。这是我目前得到的结果集的一个例子。
Line Item Region Sub Region Some Value1 Some Value 2
Some Thing Some Where 121 0 17.99 15.71
Some Thing Some Where 122 0 17.99 15.71
Some Thing Some Where 123 0 17.99 15.71
Some Thing Some Where 124 0 17.99 15.71
Some Thing Some Where 125 0 17.99 15.71
Some Thing Some Where 126 0 17.99 15.71
Some Thing Some Where 119 0 17.99 15.71
Some Thing Some Where 127 0 17.99 15.71
Some Thing Some Where 118 0 17.99 15.71
Some Thing Some Where 128 0 17.99 15.71
Some Thing Some Where 129 0 17.99 15.71
Some Thing Some Where 127 10 19.99 15.71
Some Thing Some Where 120 3 19.99 15.71
Some Thing Some Where 125 10 19.99 15.71
Some Thing Some Where 128 10 19.99 15.71
Some Thing Some Where 136 0 28.99 25.89
对于长长的清单感到抱歉,但这有助于说明这一点。现在我要做的是获得17.99值一次,然后是19.99一次,28.99一次,等等。问题是我仍然需要区域和子区域,或者至少能够回到那些,所以甚至如果我能够在19.99返回所有区域/次区域,所有区域/次区域在28.99返回,然后在17.99处返回“其他地方”。
Line Item Region Sub Region Some Value1 Some Value 2
Some Thing Some Where 999 999 17.99 15.71
Some Thing Some Where 127 10 19.99 15.71
Some Thing Some Where 120 3 19.99 15.71
Some Thing Some Where 125 10 19.99 15.71
Some Thing Some Where 128 10 19.99 15.71
Some Thing Some Where 136 0 28.99 25.89
这甚至比我目前得到的更好。如果我只使用distinct,那么它仍然会给我所有的返回,因为region / sub区域是不同的。我可以编写一个保留region / subregion列的查询,但是将其从DISTINCT检查中排除吗?