Question about subquery

Posts   
 
    
Posts: 28
Joined: 17-Oct-2004
# Posted on: 21-Sep-2006 05:39:34   

I have a view in SQL Server that contains a one (e.g. product) to many (e.g. vendors) relationship. As a result, one product may be displayed several times. Is it possible to perform the following query in LLBLGen 1.x? The product table isn't normalized 100% as it may contain two entries for products with the same name but different specs (e.g. color).

SELECT ProductName, COUNT(*) FROM (SELECT ProductID, ProductName FROM ProductView GROUP BY ProductID, ProductName) AS MyTable GROUP BY ProductName

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Sep-2006 08:46:39   

If you already are using database views, you may also create another view for the previous query. And map it back as TypedView or an Entity.

Posts: 28
Joined: 17-Oct-2004
# Posted on: 21-Sep-2006 11:38:05   

As shown in the SQL statement, my view is only part of this query. Is it possible to do this in LLBLGen or does all the SQL need to be put in a new view?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Sep-2006 14:59:22   

I was suggesting to put it all in a new view.

Posts: 28
Joined: 17-Oct-2004
# Posted on: 21-Sep-2006 16:22:00   

Is this feature available in 2.x by chance?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 21-Sep-2006 17:04:44   

No, selects from select statements ('derived tables') isn't supported, so FROM (SELECT.. FROM..) isn't supported

Frans Bouma | Lead developer LLBLGen Pro