简体   繁体   中英

Access to sql crosstab query to sql

I am trying to convert this access query to sql 2008

Can anyone convert this access query to sql?

TRANSFORM Sum(q_INTERMONTH_Union_ILIs.Total) AS SumOfTotal
SELECT q_INTERMONTH_Union_ILIs.[Billable Identifier], 
   q_INTERMONTH_Union_ILIs.[Entity Identifier]
FROM q_INTERMONTH_Union_ILIs
GROUP BY q_INTERMONTH_Union_ILIs.[Billable Identifier], 
   q_INTERMONTH_Union_ILIs.[Entity Identifier]
PIVOT q_INTERMONTH_Union_ILIs.Period;

but getting this error... anyone help

You current query in SQL Server will be similar to this:

select *
from
(
  SELECT q_INTERMONTH_Union_ILIs.[Billable Identifier], 
    q_INTERMONTH_Union_ILIs.[Entity Identifier],
    q_INTERMONTH_Union_ILIs.Period
  FROM q_INTERMONTH_Union_ILIs
) src
pivot
(
  Sum(Total)
  for Period in (yourPeriodValues go here)
) piv

In this line:

for Period in (yourPeriodValues go here)

You will place the values that you want as the columns inside of the parentheses (yourPeriodValues go here) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM