June 26, 2012 at 12:01 am
i want to divide records on daily basis like here
IF OBJECT_ID('TempDB..#mytable1','U') IS NOT NULL
DROP TABLE #mytable1
CREATE TABLE #mytable1
(
ID INT IDENTITY(1,1) ,
UName NVARCHAR(50),
alert_datetime DATETIME
)
SET IDENTITY_INSERT #mytable1 ON
INSERT INTO #mytable1
(ID, UName,alert_datetime )
SELECT '1','ABC','2011-06-06 14:12:00' UNION ALL
SELECT '2','XYZ','2011-06-06 14:12:10' UNION ALL
SELECT '3','ABC','2011-07-06 14:12:00' UNION ALL
SELECT '4','XYZ','2011-07-06 14:12:10'
SET IDENTITY_INSERT #mytable1 OFF
SELECT * from #mytable1
Now look first two records are in June and last two records in july so how i can make them different?
June 26, 2012 at 12:44 am
Methew (6/26/2012)
i want to divide records on daily basis like hereIF OBJECT_ID('TempDB..#mytable1','U') IS NOT NULL
DROP TABLE #mytable1
CREATE TABLE #mytable1
(
ID INT IDENTITY(1,1) ,
UName NVARCHAR(50),
alert_datetime DATETIME
)
SET IDENTITY_INSERT #mytable1 ON
INSERT INTO #mytable1
(ID, UName,alert_datetime )
SELECT '1','ABC','2011-06-06 14:12:00' UNION ALL
SELECT '2','XYZ','2011-06-06 14:12:10' UNION ALL
SELECT '3','ABC','2011-07-06 14:12:00' UNION ALL
SELECT '4','XYZ','2011-07-06 14:12:10'
SET IDENTITY_INSERT #mytable1 OFF
SELECT * from #mytable1
Now look first two records are in June and last two records in july so how i can make them different?
Hi Mathew,
Do you want to devide on the basis of months like Jun, Jul , Aug so on or what is the criteria ?
Please provide the expected output with few more different input entries.
--rhythmk
------------------------------------------------------------------
To post your question use below link
https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
🙂
June 26, 2012 at 12:51 am
rhythmk (6/26/2012)
Methew (6/26/2012)
i want to divide records on daily basis like hereIF OBJECT_ID('TempDB..#mytable1','U') IS NOT NULL
DROP TABLE #mytable1
CREATE TABLE #mytable1
(
ID INT IDENTITY(1,1) ,
UName NVARCHAR(50),
alert_datetime DATETIME
)
SET IDENTITY_INSERT #mytable1 ON
INSERT INTO #mytable1
(ID, UName,alert_datetime )
SELECT '1','ABC','2011-06-06 14:12:00' UNION ALL
SELECT '2','XYZ','2011-06-06 14:12:10' UNION ALL
SELECT '3','ABC','2011-07-06 14:12:00' UNION ALL
SELECT '4','XYZ','2011-07-06 14:12:10'
SET IDENTITY_INSERT #mytable1 OFF
SELECT * from #mytable1
Now look first two records are in June and last two records in july so how i can make them different?
Hi Mathew,
Do you want to devide on the basis of months like Jun, Jul , Aug so on or what is the criteria ?
Please provide the expected output with few more different input entries.
i want to devide on the basis of days like for example records of 1st June will be different from records of 2nd June.so i want to devide on daily basis.
it should be some thing like groups,for example 1st june in one group and send june in other group.
June 26, 2012 at 1:34 am
Methew (6/26/2012)
rhythmk (6/26/2012)
Methew (6/26/2012)
i want to divide records on daily basis like hereIF OBJECT_ID('TempDB..#mytable1','U') IS NOT NULL
DROP TABLE #mytable1
CREATE TABLE #mytable1
(
ID INT IDENTITY(1,1) ,
UName NVARCHAR(50),
alert_datetime DATETIME
)
SET IDENTITY_INSERT #mytable1 ON
INSERT INTO #mytable1
(ID, UName,alert_datetime )
SELECT '1','ABC','2011-06-06 14:12:00' UNION ALL
SELECT '2','XYZ','2011-06-06 14:12:10' UNION ALL
SELECT '3','ABC','2011-07-06 14:12:00' UNION ALL
SELECT '4','XYZ','2011-07-06 14:12:10'
SET IDENTITY_INSERT #mytable1 OFF
SELECT * from #mytable1
Now look first two records are in June and last two records in july so how i can make them different?
Hi Mathew,
Do you want to devide on the basis of months like Jun, Jul , Aug so on or what is the criteria ?
Please provide the expected output with few more different input entries.
i want to devide on the basis of days like for example records of 1st June will be different from records of 2nd June.so i want to devide on daily basis.
it should be some thing like groups,for example 1st june in one group and send june in other group.
Please try out ranking functions for grouping.
--rhythmk
------------------------------------------------------------------
To post your question use below link
https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply