English 中文(简体)
卡斯特服务器契约赢得拖网,但内部与集团一道,不允许文本数据型出现。
原标题:SQL Server Compact won t allow subselect but inner join with groupby not allowed on text datatype

我在我的数据库查询(SQL服务器)中使用了以下 s。

SELECT Nieuwsbrief.ID
    , Nieuwsbrief.Titel
    , Nieuwsbrief.Brief
    , Nieuwsbrief.NieuwsbriefTypeCode
    , (SELECT COUNT(*) AS Expr1 
        FROM NieuwsbriefCommentaar 
        WHERE (Nieuwsbrief.ID = NieuwsbriefCommentaar.NieuwsbriefID 
                AND NieuwsbriefCommentaar.Goedgekeurd = 1)) AS AantalCommentaren 
FROM Nieuwsbrief 

我现在要改换成serv(编版),使我能够像现在这样有子。 拟议解决办法:inner加入。 但是,由于我只需要一份子表<代码>NieuwsbriefCommentaar,我不得不使用group by 。 我的基表上的条款是为了避免结果的两倍。

然而,Nieuwbrief。 简要属性为数据类型<代码>text。 不允许在<条码>文本数据类型上按条款分类,<条码>sql-server-ce。 页: 1

任何如何解决这一问题的想法? 您的帮助。

最佳回答

我认为,解决办法可能比较容易。 我不知道你的元数据是怎样的,但我认为,这部法律仅仅使用LEFT JOIN就可以符合你的要求。

    SELECT Nieuwsbrief.ID 
    , Nieuwsbrief.Titel 
    , Nieuwsbrief.Brief 
    , Nieuwsbrief.NieuwsbriefTypeCode 
    , COUNT(NieuwsbriefCommentaar.NieuwsbriefID) AS AantalCommentaren
FROM Nieuwsbrief  
LEFT JOIN NieuwsbriefCommentaar  ON (Nieuwsbrief.ID = NieuwsbriefCommentaar.NieuwsbriefID)
WHERE NieuwsbriefCommentaar.Goedgekeurd = 1

Edited: 2ndOption

SELECT N.ID, N.Titel, N.Brief, N.NieuwsbriefTypeCode, G.AantalCommentaren  FROM Nieuwsbrief as N LEFT JOIN (SELECT NieuwsbriefID, COUNT(*) AS AantalCommentaren FROM NieuwsbriefCommentaar GROUP BY NieuwsbriefID) AS G ON (N.ID = G.NieuwsbriefID) 

请让我知道,这项法典是否发挥作用,以便找到另一个工作。

目 录

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签