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 |
|
laptop545
Starting Member
11 Posts |
Posted - 2010-01-13 : 22:17:38
|
| Given a GROUP BY with lots of variables and a need to group by all possible permutations of these variables, how would you do this without writing/running hundreds of queries? E.g. if we're grouping by id, name, and email, we would need to generate the following groupings: By nameBy emailBy idBy name, emailBy name, idBy email, idBy name, email, id 2b) write sql code to produce all permutations of a set of strings, to enable the column-name lookup and dynamic SQL as you suggested doing (note: I have not tried doing this; and don't know if it is possible. 15-minute limit does not apply.) 2c) how many permutations would we have to run for 12 variables? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-14 : 00:10:15
|
| sorry you're not clear. do you mean separate queries or you need to do this conditionally? |
 |
|
|
|
|
|