on 07-20-2010 8:53 PM
Saludos
Necesito saber si es posible dividir una columna de una consulta en varias columnas, para explicarme mejor, tengo esta tabla:
Código artículo Lista de precios Precio de lista
0000000001 Lista precios1 150.00
0000000001 Lista precios2 12.00
0000000001 Lista precios3 11.00
0000000002 Lista precios1 500.00
0000000002 Lista precios2 68.00
0000000002 Lista precios3 61.00
Con el siguiente código:
SELECT T0.ItemCode 'Código artículo', T1.ListName 'Lista de precios', T0.Price
FROM ITM1 T0
INNER JOIN OPLN T1 ON T0.PriceList = T1.ListNum
Y lo que quiero es que quede de la siguiente manera:
Código artículo Lista precios1 Lista precios2 Lista precios3
0000000001 150.00 12.00 11.00
0000000002 500.00 68.00 61.00
Si hay solución a mi problema y alguno lo sabe, le estaría muy agadecido si me pudiera ayudar
Hola...
Puedes probar el siguiente query, me parece que se ajusta a lo que requieres...
SELECT DISTINCT T0.[ItemCode], T0.[ItemName],
(SELECT T1.[Price] FROM ITM1 T1 INNER JOIN OITM Y ON T1.ItemCode = Y.ItemCode WHERE T1.PriceList = '1' AND Y.ItemCode = T0.ItemCode) as 'Lista 01',
(SELECT DISTINCT T1.[Currency] FROM ITM1 T1 INNER JOIN OITM Y ON T1.ItemCode = Y.ItemCode WHERE T1.PriceList = '1' AND Y.ItemCode = T0.ItemCode) as 'Moneda Lista 01',
(SELECT DISTINCT T1.[Price] FROM ITM1 T1 INNER JOIN OITM Y ON T1.ItemCode = Y.ItemCode WHERE T1.PriceList = '2' AND Y.ItemCode = T0.ItemCode) as 'Lista 02',
(SELECT DISTINCT T1.[Currency] FROM ITM1 T1 INNER JOIN OITM Y ON T1.ItemCode = Y.ItemCode WHERE T1.PriceList = '2' AND Y.ItemCode = T0.ItemCode) as 'Moneda Lista 02'
FROM OITM T0 INNER JOIN ITM1 T1 ON T0.ItemCode = T1.ItemCode
Conforme más listas utilices, más líneas repites en el código..
Espero te sea de ayuda
Saludos Cordiales,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Muchas gracias Paul, era exactamente lo que necesitaba
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.