By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,636 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,636 IT Pros & Developers. It's quick & easy.

Problem with Datagrid and SQL sentence

P: n/a
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
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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. :)

--
Ben Strackany
www.developmentnow.com
"ManelBIS" <Ma******@discussions.microsoft.com> wrote in message
news:B4**********************************@microsof t.com...
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

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.