sql >> データベース >  >> RDS >> Sqlserver

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. Mysql欠落している日付範囲を検索

    2. パーティションテーブル、HDD上の異なるディスク上の各パーティション

    3. MYSQL Workbench-エラー:エラー1215:外部キー制約を追加できません

    4. PLS-00386:FETCHカーソルとINTO変数の間にタイプの不一致が見つかりました