Problem with Datagrid and SQL sentence

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

We are developing a Visual Net application and we found a problem using a
datagrid with a SQL sentence that
includes the HAVING clause.

Does somebody know if exist any bug with this clause, if yes how can we do?

The SQL sentence is:

SELECT a.ORDENTRABAJO,a.DESORDENTRABAJO,Count(a.EQUIPO) AS TotalEquipos FROM
WK_OTSAP_PUENTE a
WHERE a.REALIZADA='1'
GROUP BY a.ORDENTRABAJO,a.DESORDENTRABAJO
HAVING (Count(a.EQUIPO))=(SELECT Count(*) AS total FROM WK_OTSAP_PUENTE
WHERE ordentrabajo=a.ordentrabajo)

In we run the sql sentence in the databse the result is correct, but the
datagrid shows null in each row,
althought the row number is correct!!! Without "HAVING" the datagrid runs OK

Thanks in advance
 
Can you change the SQL statement to a WHERE clause instead of HAVING?
Something like

SELECT a.ORDENTRABAJO,a.DESORDENTRABAJO,Count(a.EQUIPO) AS TotalEquipos FROM
WK_OTSAP_PUENTE a
WHERE a.REALIZADA='1' AND
Count(a.EQUIPO))=(SELECT Count(*) AS total FROM WK_OTSAP_PUENTE
WHERE ordentrabajo=a.ordentrabajo)
GROUP BY a.ORDENTRABAJO,a.DESORDENTRABAJO

I can't test it, but I think the above should work. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top