- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
SELECT *
FROM
(SELECT CASE
WHEN (CASE
WHEN datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365 = 0 THEN 'Y y.,'
ELSE cast((datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365) AS varchar(20)) + ','
END + CASE
WHEN (datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/30 - (datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365) * 12) = 0 THEN 'M m.'
ELSE cast((datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/30 - (datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365) * 12) AS varchar(20))
END) = 'Y y.,M m.' THEN ''
ELSE (CASE
WHEN datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365 = 0 THEN 'Y y.,'
ELSE cast((datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365) AS varchar(20)) + ','
END + CASE
WHEN (datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/30 - (datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365) * 12) = 0 THEN 'M m.'
ELSE cast((datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/30 - (datediff(DAY,date,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date))/365) * 12) AS varchar(20)) END)
END AS 'Возраст',
date AS date1,
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date) AS date2
FROM Battles AS P1
WHERE
(SELECT top (1) date
FROM Battles AS P2
WHERE P2.date > P1.date
ORDER BY P2.date) IS NOT NULL) AS t
UNION
(SELECT CASE
WHEN (CASE
WHEN datediff(DAY,date,CONVERT (date, GETDATE()))/365 = 0 THEN 'Y y.,'
ELSE cast((datediff(DAY,date,CONVERT (date, GETDATE()))/365) AS varchar(20)) + ','
END + CASE
WHEN (datediff(DAY,date,CONVERT (date, GETDATE()))/30 - (datediff(DAY,date,CONVERT (date, GETDATE()))/365) * 12) = 0 THEN 'M m.'
ELSE cast((datediff(DAY,date,CONVERT (date, GETDATE()))/30 - (datediff(DAY,date,CONVERT (date, GETDATE()))/365) * 12) AS varchar(20))
END) = 'Y y.,M m.' THEN ''
ELSE (CASE
WHEN datediff(DAY,date,CONVERT (date, GETDATE()))/365 = 0 THEN 'Y y.,'
ELSE cast((datediff(DAY,date,CONVERT (date, GETDATE()))/365) AS varchar(20)) + ','
END + CASE
WHEN (datediff(DAY,date,CONVERT (date, GETDATE()))/30 - (datediff(DAY,date,CONVERT (date, GETDATE()))/365) * 12) = 0 THEN 'M m.'
ELSE cast((datediff(DAY,date,CONVERT (date, GETDATE()))/30 - (datediff(DAY,date,CONVERT (date, GETDATE()))/365) * 12) AS varchar(20))
END)
END, date, CONVERT (date, GETDATE())
FROM Battles AS T1
WHERE
(SELECT top (1) date FROM Battles AS T2
WHERE T2.date > T1.date ORDER BY T2.date) IS NULL );
pedomud 12.09.2018 21:39 # +1
guest8 12.09.2018 21:58 # −999
KPAIII_TECTEP_AHYCOB 15.09.2018 14:51 # +1