Viewing 10 posts - 1 through 10 (of 10 total)
Try this
Declare @cols nvarchar(Max);
Declare @query nvarchar(Max);
Declare @tier tinyint;
Set @cols =
STUFF
(
(select ',' + Quotename(a.lbl)
from
(
select distinct DATEADD(DAY, -DAY(timestamp)+1, timestamp) ord
, 'Tier 1 GB - '+ cast(DATENAME(month,timestamp) as...
August 5, 2019 at 5:53 pm
Here is a solution. You would need to adapt it as you have more instances of each ID, but it should be pretty straightforward to change. Otherwise you can use...
April 3, 2019 at 2:43 pm
Try...
if OBJECT_ID('tempdb..#temp') is not null drop table #temp;
if OBJECT_ID('tempdb..#cte') is not null drop table #cte;
create table #temp
(
[unique_id] varchar(50) primary...
September 17, 2018 at 7:02 am
Try this:
select a.ID
,b.*
from
#TEMP a
left join #TEMP1 b on
b.ID = a.ID
and b.Letter_Type = 'C'
September 15, 2018 at 2:52 pm
Try using pivot
select p.Partitionkey
,p.Account
,p.JDEacct
,p.Entity
,p.Entityx
,p.Udx1
,p.Rule_ID
,January, February, March, April, May, June, July, August, September, October, November, December
from
(
select a.partitionkey, a.Account,a.JDEacct ,a....
August 30, 2018 at 11:46 am
If there can be potentially more items you need to use a dynamic pivot:if OBJECT_ID('tempDb.dbo.#temp') is not null drop table #temp;
create table #temp
(
...
August 29, 2018 at 9:43 am
If at most 4 items you can use this:
if OBJECT_ID('tempDb.dbo.#TestTable') is not null drop table #TestTable;
CREATE TABLE [dbo].[#TestTable] (
[PhaseId] [int] NOT NULL,
August 29, 2018 at 9:42 am
Hmm..What happens when you remove the Order By clause within the Over clause?SpikeVal/cast(count(a.Flag) over(partition by a.Fid, a.AccountNum, a.Flag , b.readDate) AS decimal(6,4))
August 28, 2018 at 7:47 am
if you are getting an error message, can you post it?
August 27, 2018 at 3:10 pm
Declare @TableA as table
(
FID numeric(8,0),
AccountNum char(9),
Spike_Reading_Day date,
SpikeVal int,
Flag char(1)
);
Try this...
Declare @TableB as table
(
FID numeric(8,0),
August 27, 2018 at 10:05 am
Viewing 10 posts - 1 through 10 (of 10 total)