SQL to transpose row pairs to columns in MS ACCESS database

ε祈祈猫儿з 提交于 2019-11-28 10:20:11

A crosstab query should suit.

TRANSFORM First([Text]) AS LangText
SELECT ID, First([Text])
FROM Table 
GROUP BY ID
PIVOT lang

Further information: http://allenbrowne.com/ser-67.html

You need a self-join:

SELECT
    t1.id, t1.text AS lang_a, t2.text AS lang_b
FROM
    lang_table AS t1
INNER JOIN
    lang_table AS t2
ON
    (t1.id = t2.id)
WHERE
    t1.lang = 'a'
AND
    t2.lang = 'b'
select a.id, a.text as 'lang A', b.text as 'lang B'
from table a join table b on (a.id = b.id)
where a.lang = 'a' and b.lang = 'b';

where "table" is whatever table these are in.

Swathi
SELECT a.id,
MAX(CASE WHEN a.lang LIKE 'a' THEN a.text) AS Lang A,
MAX(CASE WHEN a.lang LIKE 'a' THEN a.text) AS Lang A
FROM table a
GROUP BY a.id
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!