Nel

Nel

  • NA
  • 716
  • 1.1m

Problem with the sql query

Apr 25 2012 6:20 AM
Hi,
 
I have this query:
 
SELECT NALOG1.GBRV, NALOG1.DATA, Min(IIf(([NALOG1.DATA]>=[@data1]) And ([NALOG1.DATA]<=[@data2]) And ([NALOG1].[POCKM]>0) And ([NALOG1.GBRV] Between [@gbr1] And [@gbr2]),[NALOG1.POCKM],Null)) AS pockm, Max(IIf(([NALOG1.DATA]>=[@data1]) And ([NALOG1.DATA]<=[@data2]) And ([NALOG1.GBRV] Between [@gbr1] And [@gbr2]),[NALOG1.KRAJKM],Null)) AS krajkm, [krajkm]-[pockm] AS Razlika, Max(NOVI.DATAP) AS MaxOfDATAP, Max(NOVI.DATAS) AS MaxOfDATAS
 FROM NALOG1 INNER JOIN NOVI ON NALOG1.GBRV = NOVI.GBR
 GROUP BY NALOG1.GBRV, NALOG1.DATA, [krajkm]-[pockm]
 HAVING (((NALOG1.GBRV)="1001"))
 ORDER BY NALOG1.DATA;
 
and as a result I get:




GBRV
DATA
pockm
krajkm
Razlika
MaxOfDATAP
MaxOfDATAS



















































































100107.10.2011432084329385
27.09.2011
100107.10.20114310743394287
27.09.2011
100108.10.2011433944347783
27.09.2011
100108.10.20114347743580103
27.09.2011
100110.10.2011436794376687
27.09.2011
100110.10.2011435804367999
27.09.2011
100110.10.20114376643867101
27.09.2011

but I want to have one row for every date. For example for DATA=08.10.2011 instead of
GBRV DATA pockm krajkm Razlika MaxOfDATAP MaxOfDATAS
1001 08.10.2011 43394 43477  83 27.09.2011
1001 08.10.2011 43477 43580  103 27.09.2011
I want to have :
GBRV DATA  pockm krajkm Razlika MaxOfDATAP MaxOfDATAS
1001 08.10.2011 43394 43580  83  27.09.2011

Could anybody help me please? Thanks very much in advance.






Answers (1)