0
Declare @a TABLE(diffBY30 DATETIME)
INSERT INTO @a(diffBY30)
Select
Convert(int, DateDiff(D,MaxDate, MinDate))/30 as diff
from(
SELECT(Select CAST( Max
(o.Created) AS DATETIME)) AS MaxDate
,(select CAST( MIN(o.Created) AS DATETIME)) as MinDate
from [Order] AS o)A
select * from @a
Group by diffBY30
0
How to apply count operation over this query for calculating number of same DIFF,
such as if after diff values are 10, 2,10,10,3
then it give result after count that 10 is 3 times, 2 is once etc.
my query is
SELECT
MaxDate,
MinDate,
DATEDIFF(D, MinDate, MaxDate)/30 AS DIFF
FROM (
SELECT
MAX(TDate) AS MaxDate,
MIN(TDate) AS MinDate
FROM EDATA
GROUP BY TCard
)a
0
Heyy Ramesh!
what if i want to store that diff into same table but in a new column ?
0
Declare @a TABLE(diffBY30 DATETIME)
INSERT INTO @a(diffBY30)
Select
Convert(int, DateDiff(D,MaxDate, MinDate))/30 as diff
from(
SELECT(Select CAST( Max
(o.Created) AS DATETIME)) AS MaxDate
,(select CAST( MIN(o.Created) AS DATETIME)) as MinDate
from [Order] AS o)A
select * from @a
In this example @a table is your Tab2