[QUOTE=ComeToTheDarkSideWeHaveCookies]
My apologies if this may have been answered already.
I’ve been trying to figure out how to use Excel to get around some shortcomings in an SQL querey I have to use to run some reports.
Basically, the SQL querey results include both missing AND redundant data.
For the sake of example, Column A includes Account Numbers, Column B is an “important account factor”, and Column C includes Usernames (belonging to the acct # in Column A).
Acct #,Acct factor,Username
1,b,jon
1,b,sam
1,null,sam
1,null,ben
1,null,tim
2,c,val
2,null,ted
2,c,ted
3,null,ned
3,null,ned
3,null,ken
3,null,liv
What I want the endpoint to be is the basically a lowest common denominator of Column A and Column B. I process Column C with a seperate function, but I need them for analytical context of Column A and B. Not all account numbers have account factors (in the absence of a factor in any “Acct factor” field for any given “Acct #”, null is the valid state). I need to display the appropriate “Acct factor” state for each account number.
This is what I’d want to get out of the above data when all is said and done:
Acct #,Acct factor,Username
1,b,sam (or jon, ben, or tim, but only one)
2,c,val (or ted, but not both)
3,null,ned (or ken, or live, but only one)
This has been driving me CRAZY.
I hope you can help me.
Thanks in advance!
[/QUOTE]
So you thought you’d drive me crazy as well … hey, that’s what I’m here for. But I don’t understand what your end result is to be, so before I go further, let me see if I got it.
It seems that the rules for a given Acct # are
-
if some of the Acct factors are not null, list one of them with a corresponding name.
-
if all of the Acct factors are null, list one of them with a corresponding name.
Is this correct?
Do we ever output more than one line for each account factor?
In your example, for Account 1, jon and sam have “b” and “null”, while tim and ben just have “null”. Why is the answer “b” and any of the four name?
Does an Acct # ever have more than one factor? (two if we count null)
Get back to me on this one and we’ll give it a shot.
Morning to all (here at least),
w.