0

When running the query below I am getting the following error:

Error Code: 1054. Unknown column 'SLI_nuevo.id_oc' in 'field list'

Select SLI_nuevo.id_oc, cantidad_OC, Cant_rec, Total_OC-REC_$ as DIF_$
From (Select SLI_nuevo.id_oc as oc,sum(cantidad) as cantidad_OC,sum(fob*cantidad) as Total_OC
From SLI_nuevo group by id_oc) SLI_nuevo left join (Select NROOC, sum(cant_rec) as Cant_rec, sum(fob*cant_rec) as REC_$
From SLI_nuevo left join oc_contenedores_odbms on SLI_nuevo.sku=oc_contenedores_odbms.SKU group by NROOC)
oc_contenedores_odbms on SLI_nuevo.id_oc=oc_contenedores_odbms.NROOC
Group by oc;

How can I fix this?

Blackbam
  • 17,496
  • 26
  • 97
  • 150
user127870
  • 11
  • 2

1 Answers1

1

As @GileBrt said in his edit, this is an English speaking website, so you should make your question in English.

The problem you have is that you have renamed your column with an alias, so now the name of your column is SLI_nuevo.oc not SLI_nuevo.id_oc because you have used an alias:

Select SLI_nuevo.oc, cantidad_OC, Cant_rec, Total_OC-REC_$ as DIF_$
From (Select SLI_nuevo.id_oc as oc,sum(cantidad) as cantidad_OC,sum(fob*cantidad) as Total_OC
      From SLI_nuevo group by id_oc) SLI_nuevo 
left join (Select NROOC, sum(cant_rec) as Cant_rec, sum(fob*cant_rec) as REC_$    
           From SLI_nuevo left join oc_contenedores_odbms on SLI_nuevo.sku=oc_contenedores_odbms.SKU 
           group by NROOC) oc_contenedores_odbms on SLI_nuevo.id_oc=oc_contenedores_odbms.NROOC
Group by oc;
nacho
  • 5,280
  • 2
  • 25
  • 34
  • Thanks, I did not know that the questions were only in English. I saw the error and remove the alias, but now it shows me the following error “Error Code: 2013. Lost connection to MySQL server during query” – user127870 Jun 05 '19 at 15:00
  • That's because your query takes too much time or your time out it is very low. If you are using Workbench, take a look at this question https://stackoverflow.com/questions/10563619/error-code-2013-lost-connection-to-mysql-server-during-query – nacho Jun 05 '19 at 15:20