M
Marco
Hello.
I have a list of productions of products with the dates that they were
produced.
but I have to make a query that returns me per product the oldest produced
date.
When I do order by Date it makes the oldes to be on the top but when I group
to get the first it doesn't works.
I have this:
DataProducao DataValidade CodigoInterno
09-04-2008 09-04-2011 10056
21-11-2007 21-11-2012 14652
05-12-2007 05-12-2012 14652
07-12-2007 07-12-2012 14652
19-11-2007 19-11-2012 14652
06-12-2007 06-12-2012 14652
06-12-2007 06-12-2012 14652
and I nedd to have this:
DataProducao DataValidade CodigoInterno
09-04-2008 09-04-2011 10056
19-11-2007 19-11-2012 14652
I'm doing this:
SELECT First([27_tbl_StockEnviado_por_Expedicao_Lotes].DataProducao) AS
FirstOfDataProducao,
First([27_tbl_StockEnviado_por_Expedicao_Lotes].DataValidade) AS
FirstOfDataValidade, [21_tbl_StockEnviado_por_Expedicao].CodigoInterno
FROM 21_tbl_StockEnviado_por_Expedicao INNER JOIN
27_tbl_StockEnviado_por_Expedicao_Lotes ON
[21_tbl_StockEnviado_por_Expedicao].ID =
[27_tbl_StockEnviado_por_Expedicao_Lotes].ID_LinhaExpedicao
GROUP BY [21_tbl_StockEnviado_por_Expedicao].CodigoInterno;
Any help is very much appreciated.
Regards,
Marco
I have a list of productions of products with the dates that they were
produced.
but I have to make a query that returns me per product the oldest produced
date.
When I do order by Date it makes the oldes to be on the top but when I group
to get the first it doesn't works.
I have this:
DataProducao DataValidade CodigoInterno
09-04-2008 09-04-2011 10056
21-11-2007 21-11-2012 14652
05-12-2007 05-12-2012 14652
07-12-2007 07-12-2012 14652
19-11-2007 19-11-2012 14652
06-12-2007 06-12-2012 14652
06-12-2007 06-12-2012 14652
and I nedd to have this:
DataProducao DataValidade CodigoInterno
09-04-2008 09-04-2011 10056
19-11-2007 19-11-2012 14652
I'm doing this:
SELECT First([27_tbl_StockEnviado_por_Expedicao_Lotes].DataProducao) AS
FirstOfDataProducao,
First([27_tbl_StockEnviado_por_Expedicao_Lotes].DataValidade) AS
FirstOfDataValidade, [21_tbl_StockEnviado_por_Expedicao].CodigoInterno
FROM 21_tbl_StockEnviado_por_Expedicao INNER JOIN
27_tbl_StockEnviado_por_Expedicao_Lotes ON
[21_tbl_StockEnviado_por_Expedicao].ID =
[27_tbl_StockEnviado_por_Expedicao_Lotes].ID_LinhaExpedicao
GROUP BY [21_tbl_StockEnviado_por_Expedicao].CodigoInterno;
Any help is very much appreciated.
Regards,
Marco