sql >> Database teknologi >  >> RDS >> Sqlserver

Unionskolonner lodret i SQL

SELECT [PR].[Id], [PR].[Name], [PR].[GroupId], [GR].[Title] AS [Group], [PR].[CategoryId], [CA].[Title] AS [Category], ISNULL([PD].[Id], CAST(-1 AS BIGINT)) AS [ProductDealerId], ISNULL([D].Id, CAST(-1 AS BIGINT)) as DealerId, ISNULL([D].Name, CAST('HaveNotDealer' AS NVARCHAR)) as DealerName, ISNULL(PD.LastSale, CAST('0001-01-01 00:00:01' AS DATETIME2)) as LastSale, ISNULL([PD].Number, CAST(0 AS BIGINT)) as SaleNumber FROM [dbo].[Product] AS [PR] INNER JOIN [dbo].[Group] AS [GR] ON [PR].[GroupId] = [GR].[Id] INNER JOIN [dbo].[Category] AS [CA] ON [PR].[CategoryId] = [CA].[Id] LEFT OUTER JOIN [dbo].[ProductDealer] AS [PD] ON [PR].[Id] = [PD].[ProductId] LEFT OUTER JOIN [dbo].[Dealer] AS [D] ON [PD].DealerId = [D].Id

  1. Sådan installeres MariaDB 10 på RHEL 8

  2. Enkelte eller flere databaser

  3. LYT forespørgsel timeout med node-postgres?

  4. Hvordan finder man næsten lignende poster i sql?