sql server的sql语句准备转成mysql

SELECT
 SUM(TransactionList.UniqueCust) AS UniqueChargedUsers,
 ItemList.ItemID,
 ProductName,
 TransactionList.ArtistName,
 TransactionList.ArtistID,
 AlbumList.AlbumName,
 AlbumList.AlbumID,
 CPList.ContentProviderName,
 TransactionList.CreateDate,
 ItemList.ContentProviderID,
 SUM(TransactionList.Request) AS TotalCount,
 TransactionList.ItemType,
 TransactionList.Price,
 SUM(TransactionList.Gross) AS GrossRevenue,
 TransactionList. STATUS
FROM
 (
  SELECT
   Count(DISTINCT Customer) AS UniqueCust,
   ItemId AS ContentID,
   Count(*) AS Request,
   ItemType,
   CONVERT (VARCHAR(10), CreateDate, 102) AS CreateDate,
   (
    SELECT
     [ Name_other ]
    FROM
     dbo.ViewArtistName
    WHERE
     dbo.ViewArtistName.ArtistID = (
      SELECT
       TOP 1 ArtistID
      FROM
       dbo.ItemArtist
      WHERE
       dbo.ItemArtist.ItemID = TransactionInfo.ItemId
     )
   ) AS ArtistName,
   (
    SELECT
     TOP 1 ArtistID
    FROM
     dbo.ItemArtist
    WHERE
     dbo.ItemArtist.ItemID = TransactionInfo.ItemId
   ) AS ArtistID,
   Price,
   Price * (Count(*)) AS Gross,
   STATUS,
   Paid,
   MediaCode = CASE
  WHEN isNumeric (
   SUBSTRING(
    attribute,
    CHARINDEX (
     'MaxisMediaCode=',
     attribute
    ) + len ('MaxisMediaCode='),
    2
   )
  ) >= 1 THEN
   SUBSTRING(
    attribute,
    CHARINDEX (
     'MaxisMediaCode=',
     attribute
    ) + len ('MaxisMediaCode='),
    2
   )
  ELSE
   '00'
  END
  FROM
   [ AortaDB ].[ dbo ].[ TransactionInfo ]
  WHERE
   Attribute NOT LIKE '%redownload=Y%'
  AND CHARINDEX (
   'MaxisMediaCode=',
   attribute
  ) > 0
  AND Price IS NOT NULL
  AND Price != '0.00'
  AND ParentTransCode IS NULL
  AND Channel <> 'Streaming'
  AND Attribute NOT LIKE '%ServiceType=UNLMITED_MUSIC%'
  AND CONVERT (VARCHAR(10), CreateDate, 102) = < Date >
  AND ItemType = < ItemType >
  AND Channel = < Channel >
  GROUP BY
   ItemId,
   CONVERT (VARCHAR(10), CreateDate, 102),
   Price,
   Customer,
   STATUS,
   Paid
 ) TransactionList
INNER JOIN (
 SELECT
  V1.ItemID AS ItemID,
  (
   SELECT
    LanguageType + ' | '
   FROM
    dbo.viewItemInfo V2
   WHERE
    V2.ItemID = V1.ItemID
   AND LanguageType != 'Other' FOR XML PATH ('')
  ) AS OriLang,
  MAX(VALUE) AS ProductName,
  contentProviderID AS ContentProviderID
 FROM
  dbo.viewItemInfo V1
 WHERE
  V1.LanguageType = 'Other'
 GROUP BY
  V1.ItemID,

 VALUE
  ,
  contentProviderID,
  ItemType
) ItemList ON TransactionList.ContentID = ItemList.ItemID
INNER JOIN (
 SELECT
  dbo.ContentProviderInfo.ContentProviderID AS ContentProviderID,
  dbo.ContentProviderInfo. NAME AS ContentProviderName
 FROM
  dbo.ContentProviderInfo
 WHERE
  ContentProviderID = < ContentProviderID >
) CPList ON ItemList.ContentProviderID = CPList.ContentProviderID
LEFT OUTER JOIN dbo.ItemAlbum ON ItemList.ItemID = dbo.ItemAlbum.ItemID
LEFT OUTER JOIN (
 SELECT
  dbo.ViewAlbumInfo.AlbumID AS AlbumId,
  dbo.ViewAlbumInfo.
 VALUE
  AS AlbumName
 FROM
  dbo.ViewAlbumInfo
 WHERE
  dbo.ViewAlbumInfo.LanguageType = 'Other'
) AlbumList ON dbo.ItemAlbum.AlbumID = AlbumList.AlbumId
GROUP BY
 CPList.ContentProviderName,
 ItemList.ContentProviderID,
 TransactionList.CreateDate,
 TransactionList.Price,
 AlbumList.AlbumName,
 AlbumList.AlbumID,
 ItemList.ItemID,
 ItemList.ProductName,
 TransactionList.ArtistName,
 TransactionList.ArtistID,
 TransactionList. STATUS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值