Возможно ли создание такого запроса в Terrasoft?
SELECT
[tbl_Application].[CarID] AS [CarID],
[tbl_Car].[Name] AS [NameCarID],
[tbl_Application].[ContactID] AS [ContactID],
[tbl_Contact].[Name] AS [NameContactID],
[tbl_Contact].[Communication1] AS [Communication1],
[tbl_Application].[Date] AS [Date],
[tbl_Application].[Name] AS [Name],
[tbl_Application].[Number] AS [Number],
[tbl_Application].[SummaOstatok] AS [SummaOstatok],
[tbl_Application].[SummaDiscount] AS [SummaDiscount],
[tbl_Application].[CheckBroken] AS [CheckBroken],
[tbl_Application].[TypeID] AS [TypeID],
[tbl_ApplicationType].[Name] AS [NameTypeID],
(SELECT COUNT(App.ID)
FROM tbl_Application AS App
WHERE App.CarID = tbl_Application.CarID
GROUP BY App.CarID) AS [Kvo]
FROM
[dbo].[tbl_Application] AS [tbl_Application]
LEFT OUTER JOIN
[dbo].[tbl_Car] AS [tbl_Car] ON [tbl_Car].[ID] = [tbl_Application].[CarID]
LEFT OUTER JOIN
[dbo].[tbl_Contact] AS [tbl_Contact] ON [tbl_Contact].[ID] = [tbl_Application].[ContactID]
LEFT OUTER JOIN
[dbo].[tbl_ApplicationType] AS [tbl_ApplicationType] ON [tbl_ApplicationType].[ID] = [tbl_Application].[TypeID]
ORDER BY
[Kvo] DESC,
2 ASC,
4 ASC,
6 ASC,
13 ASC
Собственно интересует строчка - [Kvo] DESC
Нравится