Viewing 15 posts - 31 through 45 (of 58 total)
Here is required output
('577', '-1','1','2021-02-14');
('563', '-1','1','2021-02-13')
February 24, 2022 at 8:15 pm
or please share me any other query which will show max of last 2 days
February 24, 2022 at 5:57 pm
here is the query
SELECT Div_ID,
CustomerID,
Div_Status,
LogDate ,
LogDate
FROM ( SELECT Div_ID,
CustomerID,
Div_Status,
LogDate,
LAG(Div_Status,1,0) OVER (PARTITION BY Div_ID ORDER BY logdate) AS PreviousValue,
LEAD (Div_Status,0,1) OVER (PARTITION BY Div_ID ORDER BY logdate) as NextValue
FROM dbo.Table_1
) AS...
February 24, 2022 at 5:44 pm
can not select top2 logdate along with other columns when really not required
February 24, 2022 at 3:47 pm
Please do not use top(2) . i can not use in my existing query ..help me with alternatives
February 24, 2022 at 2:36 pm
Sorry, here is input data for last 2 max days
INSERT INTO [dbo].[Table_1]
([div_id]
,[customerid]
,[div_status]
,[logdate])
VALUES
('563', '-1','1','2021-02-13'),
('577', '-1','1','2021-02-12'),
('577', '-1','1','2021-02-10');
February 24, 2022 at 2:12 pm
sorry -1 mistakenly came. it is 1 only in the first row
February 23, 2022 at 8:10 am
Actually more data loaded.. So instead of 1,01,0 records more 1,1,1 values coming div_status
February 23, 2022 at 3:17 am
output is getting more 1,1,1 records 1,0,1,0..Any suggestion...
February 22, 2022 at 7:42 pm
Hi Expert,
here is the query
Create table statement
CREATE TABLE [dbo].[Table_1](
[div_id] [nchar](10) NULL,
[customerid] [nchar](10) NULL,
[div_status] [nchar](10) NULL,
[logdate] [date] NULL
) ON [PRIMARY]
GO
Insert Data:
INSERT INTO [dbo].[Table_1]
([div_id]
,[customerid]
,[div_status]
,[logdate])
VALUES
('495','-1','-1','2021-02-14'),
('495','-1' ,'1','2021-02-14'),
('495','-1' ,'1','2021-02-14'),
('502' ,'-1', '1','2021-02-14'),
('513', '-1','1','2021-02-14'),
('538', '-1','1','2021-02-14'),
('545', '-1','1','2021-02-14'),
('563', '-1','1','2021-02-14'),
('577',...
February 22, 2022 at 5:16 am
Attached excel sheet
February 21, 2022 at 8:10 pm
Hi Expert,
I pump more data and tried to get values 1,0(active and inactive) order by logdate but even changing in queries not getting proper values for whole table. Sample data...
February 21, 2022 at 8:09 pm
Table is attached in excel sheet due to format issue
February 18, 2022 at 4:22 pm
Viewing 15 posts - 31 through 45 (of 58 total)