Hello,
I am new to sql and have inherited a project that has my grey hair turning silver exponentially. You've all been of great assistance before, I hope you will be able to help me now as well.
The following code is part of a stored procedure that is used on a GL account report. For each transaction you can have multiple details <basically comment fields that describe what the purchases were for>
Apparantly to the code author thought this was the most effiecent way to handle this. This code is above another select statement. What is happening is that if both Detail one and detail two are null in the GLcode table, this temp table is being populated with duplicates. Before these fields were not allowed to be null, now they are and I am not sure how to adjust this.
The result that is needed is for each transaction we only have one row.
what we are getting instead is 912 is listed twice.
there is a left outer join to this table that is used to display this data based on the transaction
Thanks for any assistance
Julie
CRXI CE10 / RS2005 Sql DB
I am new to sql and have inherited a project that has my grey hair turning silver exponentially. You've all been of great assistance before, I hope you will be able to help me now as well.
The following code is part of a stored procedure that is used on a GL account report. For each transaction you can have multiple details <basically comment fields that describe what the purchases were for>
Apparantly to the code author thought this was the most effiecent way to handle this. This code is above another select statement. What is happening is that if both Detail one and detail two are null in the GLcode table, this temp table is being populated with duplicates. Before these fields were not allowed to be null, now they are and I am not sure how to adjust this.
Code:
select transaction,max(GLCode.Detail1) Detail1,max(GLcode.detail2) Detail2
INTO #Temp
from GLcode
group by transaction
INSERT INTO #Temp
select transaction,max(GLCode.Detail1) Detail1,max(GLcode.detail2) Detail2
from GLcode
group by transaction
The result that is needed is for each transaction we only have one row.
Code:
Transaction Detail1 Detail2
123 oops broke
345 ding
678 dong
912
what we are getting instead is 912 is listed twice.
there is a left outer join to this table that is used to display this data based on the transaction
Thanks for any assistance
Julie
CRXI CE10 / RS2005 Sql DB