I have a query that's being use in my application. I had to make a small edit to it (select an additional column) and now that I do that, I don't get the same results, therefore I get a bad file. Just to give example this is what the query looks like ....
Select
'X' = tblA.VendorNumber,
'Y' = tblB.Label,
'Z' = tblC.InvoiceNo,
'W' = tblD.Checks,
From //Doing some joins here
Group By
tblA.VendorNumber, tblB.label, tblc.InvoiceNo, tblD.Checks
The result set gives me many records, but groups by the ones with identical X,Y,Z,W - so with no Group By it would look like this
X Y Z W
-----------------------------------------------------------
123 Anton 772 0
123 Anton 772 0
Obviously, with the group by they are rolled up into one...
The issue comes when I try to include an additional column in my Select
query. I need this query in my, because I need to value in my code to be able to distinguish what type of record it is. With the new column, these two rows of data are not the same, therefore they do not get rolled up.
Is there a way for me to somehow add an additional column, but not display it, and exclude it from the Group By
?
This is what I mean
Select
'X' = tblA.VendorNumber,
'Y' = tblB.Label,
'Z' = tblC.InvoiceNo,
'W' = tblD.Checks,
'P' = tblC.Proc -- New column
From //Doing some joins here
Group By
tblA.VendorNumber, tblB.label, tblc.InvoiceNo, tblD.Checks,
tblC.Proc -- New column
In this case the data looks like this
X Y Z W P
---------------------------------------------------------------------
123 Anton 772 0 FPN
123 Anton 772 0 PPN
So now that P is different for the 2 records that previously were rolled up into one, is there a way for me to somehow not display P, however, still be able to get it's value from my record set. I am unable to select the 'P' if it's not selected in this one query and because of the fact that the two records are not rolling up, I'm having some major issues.
Basically I need to select 'P' but not include it in my result set or group by.
Any help would be much appreciated.