Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select count(*) as countForType,
- SUM(typeTable.amount) as totalForType,
- case
- when ( charindex('[', typeTable.source) > 0 and
- charindex(']', typeTable.source) > 0)
- then substring( typeTable.source,
- charindex('[', typeTable.source) +1,
- (charindex(']', typeTable.source) - 1) - charindex('[', typeTable.source))
- else null
- end
- as country
- FROM theTypeTable typeTable (nolock)
- WHERE typeTable.startDate > @fromDate
- AND typeTable.startDate < @toDate
- AND typeTable.source like @source
- GROUP BY
- case
- when ( charindex('[', typeTable.source) > 0 and
- charindex(']', typeTable.source) > 0)
- then substring( typeTable.source,
- charindex('[', typeTable.source) +1,
- (charindex(']', typeTable.source) - 1) - charindex('[', typeTable.source))
- else null
- end
- countForType totalForType country
- =========================================
- 590 82983909 en-US
- 689 93893829 de-CH
- 239 12738392 tr-TR
- countForType totalForType country
- =========================================
- 590 82983909 NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement