我有一个事件页面,我需要根据网址中的值重定向或重写。
该页面生成以下网址:
www.website.com/booking/?event=value1&date=value2&noa=value3
我希望根据第一个值重定向,无论之后是什么,如果event=new-event
它将重定向到:
www.website.com/booking/value-1
答案 0 :(得分:0)
C#代码背后:
DECLARE @SQL NVARCHAR(MAX) = '
WITH
TestData as (
SELECT TestName, CONVERT(DECIMAL(10,2),result) as TestResult
FROM TestReg
WHERE ResultDate BETWEEN @pFromDate AND @pToDate
and (testrgstr_testname like ''%Sludge%''
or testrgstr_testname like ''%Dust%''
or testrgstr_testname like ''%Particle%'')
)'
DECLARE @InnerSelectSQL NVARCHAR(MAX) = N''
IF (@pCampType = 'JAMES')
@InnerSelectSQL = N'
SELECT [JDTD JAMES Cutting Sludge AT] as s_at, [JDTD JAMES Cutting Sludge AO] as s_ao,
[JDTD JAMES Dust AT] as d_at, [JDTD JAMES Dust AO)] as d_ao,
[JDTD JAMES Particle_AT] as p_at, [JDTD JAMES Particle_AO] p_ao '
ELSE IF (@pCampType = 'FRANK')
@InnerSelectSQL = N'
SELECT [JDTD FRANK Cutting Sludge AT] as s_at, [JDTD JAMES FRANK Sludge AO] as s_ao,
[JDTD FRANK Dust AT] as d_at, [JDTD FRANK Dust AO)] as d_ao,
[JDTD FRANK Particle_AT] as p_at, [JDTD FRANK Particle_AO] as p_ao '
SET @SQL = @SQL + CHAR(13) + CHAR(10) + InnerSelectSQL + CHAR(13) + CHAR(10) + N'
FROM TestData
PIVOT
(
avg(TestResult)
FOR testrgstr_testname
IN ([JDTD JAMES Cutting Sludge AT],[JDTD JAMES Cutting Sludge AO],
[JDTD JAMES Dust AT, [JDTD JAMES Dust AO],
[JDTD JAMES Particle_AT],[JDTD JAMES Particle_AO])
) as pvt'
Dynamic SQL is uglier, but you avoid repetition.