Re: Problem with Datagrid and SQL sentence

From: Ben Strackany (infoNOSPAM_at_developmentnow.nospam.com)
Date: 01/05/05


Date: Wed, 5 Jan 2005 11:02:53 -0600

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" <ManelBIS@discussions.microsoft.com> wrote in message
news:B4F681B6-CC3B-4608-906C-668A4266C128@microsoft.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


Relevant Pages

  • Re: Better "Join" vs "Where" clause?
    ... running the SQL directly, in the SQL Server tools, rather than ... WHERE clause has been deprecated, ... AFAIK one cannot perform an outer join in Access without using the explicit ...
    (microsoft.public.access.queries)
  • Re: Performance degradation with view and "left outer join" vs. "from x, outer y"
    ... Turned Every Which Way But Loose", I reminded the attendees that the ANSI SQL '92 parsing rules REQUIRE that filters in the WHERE clause of a query MUST be processed POST-JOIN in order for an RDBMS to be compliant. ... That means that your filter, c.custid = "AB1234", is applied after all rows of the customer table have been LEFT OUTER JOINed to the my_view VIEW with the results stored into a temp table. ... Now if I use the informix extended outer join syntax: ...
    (comp.databases.informix)
  • Re: the "having" clause
    ... Start in the FROM clause and build a working table from all of the ... rest of the containing query. ... e) Go to the SELECT clause and construct the expressions in the list. ... As you can see, things happen "all at once" in SQL, not from left to ...
    (microsoft.public.sqlserver.programming)
  • Re: Report Parameters - no results
    ... Allen Browne - Microsoft MVP. ... I did use the WHERE clause you suggested, and now I'm getting the "wrong ... > What else can I do to try to correct my sql? ... >> the WHERE clause in your query. ...
    (microsoft.public.access.reports)
  • Re: export form filtered data to excel
    ... ' There's no ORDER BY in the SQL. ... ' Remove the semi-colon from the end, then append the WHERE clause ... Or, better yet, look at the actual SQL for your query and see what's ...
    (microsoft.public.access.formscoding)