In a stored procedure (with many nested select statements) I am trying to split one particular record into 2 equal records with equal values. So, for example, if I come across a record with a description of "dog" and it has an associated numeric value of 30, I want to split it into 2 records both with a description of "dog" with numeric values of 15 for each. I want to do this for each period in a fiscal year.
What I am struggling with is this statement:
select Aname
,CASE WHEN Aname = 'dog' THEN Round(p1/2, 0) ELSE p1 END
This only creates a single record (1 column) because of the ELSE statement. How do I create a 2nd row (record). Keep in mind this is just for display, it won't change the database.
Sample of code:
What I am struggling with is this statement:
select Aname
,CASE WHEN Aname = 'dog' THEN Round(p1/2, 0) ELSE p1 END
This only creates a single record (1 column) because of the ELSE statement. How do I create a 2nd row (record). Keep in mind this is just for display, it won't change the database.
Sample of code:
Code:
USE [test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[test_proc]
@var1 int,
@var2 varchar(10)
AS
BEGIN
DECLARE temp int
select Aname
,CASE WHEN Aname = 'dog' THEN Round(p1/2, 0) ELSE p1 END
from
(select list…..
from
(select list…..
from dbDog a, dbDogList b
where a.key = b.key
and …..) temptable
group by ….) temptable2) temptable3
group by … )temptable4 where ….
and….)temptable5
order by ……
DROP TABLE #PeriodEndDates
END