Unexpected Results Query of Queries

assume you have a query named q1 with more than 1 record.
What would expect to q2 to look like?
<cfquery name="q2" dbtype="query">
select count(*) as abc from q1
where 1 = 2
</cfquery>
If you run it, were your expections met? Mine certainly were
not.

quote:
Originally posted by:
CRidgway
What I expect (and use in apps I write when needed) is the
result from the 2nd query should be:
q2.recordcount = 1
q2.fieldlist = "abc"
q2.abc = 0
Running these types of queries directly against MS SQL and MS
Access yields the results listed above. In the case of the QoQ
results, the recordcount is 0 thus abc is not defined.
CR
Aww, you gave away the answer. This scenario (different sql
of course) happened to me this afternoon. I couldn't believe it. In
any event I handled it in the template I was working on and logged
a bug to Adobe.

Similar Messages

  • Combining results with a Query of Queries - NOT QUITE THERE!!!

    I have included a small sample of my database, specifically the four tables I am trying to work with in the hopes that someone can steer me down the right path. Here are the four tables and the bottom is a visual desciption of what I am trying to achieve;
    ORDERS
    SALES CALLS
    ID
    SaleDate
    TerritoryManager
    UserID
    SaleDate
    TerritoryManager
    ID
    UserID
    426
    01-Oct-09
    Mike B
    10112
    10/1/2009
    Mike  B
    253
    10112
    427
    01-Oct-09
    Russ  C
    10115
    10/1/2009
    Mike  B
    254
    10112
    430
    01-Oct-09
    Jerry W
    10145
    10/1/2009
    Mike  B
    255
    10112
    432
    01-Oct-09
    Ron  H
    10118
    10/1/2009
    Mike  B
    256
    10112
    433
    01-Oct-09
    Ron H
    10118
    10/1/2009
    Ron  H
    257
    10118
    10/1/2009
    Ron  H
    258
    10118
    PRODUCTS ORDERED
    10/1/2009
    Ron  H
    260
    10118
    OrderID
    Quantity
    NewExisting
    UserID
    10/1/2009
    Russ  C
    261
    10115
    426
    12
    0
    10112
    10/1/2009
    Mike  B
    267
    10112
    427
    2
    0
    10115
    10/1/2009
    Mike  B
    268
    10112
    427
    3
    1
    10115
    430
    1
    0
    10145
    USERS
    430
    1
    0
    10145
    TerritoryManager
    Zone
    UserID
    432
    1
    0
    10118
    Mike B
    Central
    10112
    432
    1
    0
    10118
    Russ  C
    Central
    10115
    432
    1
    1
    10118
    Jerry W
    Central
    10145
    432
    1
    1
    10118
    Ron  H
    Central
    10118
    433
    2
    1
    10120
    Don  M
    Central
    10120
    Central Zone
    Ttl Calls
    Ttl Orders
    Ttl Items
    Ttl New Items
    Mike B
    5
    1
    12
    1
    Russ  C
    1
    1
    5
    Jerry W
    1
    2
    Ron  H
    3
    2
    6
    3
    I have tried to achieve this result in many ways to no avail. If I try to combine PRODUCTS ORDERED with ORDERS I get an erroneous count. I finally resigned myself to getting all the info I needed with separate queries and then trying to combine them with a query of queries. This worked fine until the last query of queries which timed out with no results. I am a newbie and would appreciate any constructive help with this. I am including my queries below as well;
    <cfquery name="qGetOrders" datasource="manna_premier">
    SELECT Count(Orders.ID) AS CountOfID,
           Orders.UserID AS Orders_UserID,
        Users.UserID AS Users_UserID,
        Users.TMName
    FROM Users INNER JOIN Orders ON Users.[UserID] = Orders.[UserID]
    GROUP BY Orders.UserID, Users.UserID, Users.TMName;
    </cfquery>
    <cfquery name="qGetSalesCalls" datasource="manna_premier">
    SELECT Count(Sales_Calls.ID) AS CountOfID,
           Users.UserID AS Users_UserID,
        Users.TMName,
        Sales_Calls.UserID AS Sales_Calls_UserID
    FROM Users INNER JOIN Sales_Calls ON Users.[UserID] = Sales_Calls.[UserID]
    GROUP BY Sales_Calls.UserID, Users.UserID, Users.TMName;
    </cfquery>
    <cfquery name="qGetProducts" datasource="manna_premier">
    SELECT Count(ProductOrders.OrderID) AS CountOfOrderID,
           Sum(ProductOrders.Quantity) AS SumOfQuantity,
        Sum(ProductOrders.NewExisting) AS SumOfNewExisting,
        ProductOrders.UserID
    FROM Orders INNER JOIN ProductOrders ON Orders.[ID] = ProductOrders.[OrderID]
    GROUP BY ProductOrders.UserID;
    </cfquery>
    <cfquery name="qqCombOrd_Prod" dbtype="query">
    SELECT *
    FROM qGetOrders, qGetProducts
    </cfquery>
    <cfquery name="qqCombOrd_ProdtoSales" dbtype="query">
    SELECT *
    FROM qqCombOrd_Prod, qGetSalesCalls
    </cfquery>
    PLEASE HELP!!! I'm about to go scouting for bridges to leap from!

    You might be able to simplify that query by getting rid of the subqueries.  Something like this
    SELECT TerritoryManager
    , count(sc.userid) totalcalls
    , sum(po.quantity) total
    , sum(newexisting) totalnew
    , count(o.userid) totalorders
    from users u join salescalls sc on u.userid = sc.userid
    join orders o on u.userid = o.userid
    join productorders po on u.userid = po.userid
    where userzone = 'CENTRAL'

  • Using coldfusion variables in sql queries, some unexpected results.

    I've come across a somewhat perplexing problem. I'd be
    interested to see if the following works for other people:
    <cfset sql_var = "'something','something else'">
    <cfquery name="test" datasource="db">
    select id from table where somename in (#sql_var#)
    </cfquery>
    As it is this produces a sql error - coldfusion tries to run
    the query as
    select id from table where somename in
    (''something'',''something else'')
    That's with double single quotes around each of the strings,
    even though this wasn't specified in the variable sql_var.
    So I tried this:
    <cfset sql_var = "something','something else">
    <cfquery name="test" datasource="db">
    select id from table where somename in ('#sql_var#')
    </cfquery>
    Where variable sql_var only has single quotes in between the
    two strings, and I've added single quotes to the select statement.
    This produces no error, but no results either. The sql being run is
    select id from table where somename in
    ('something','something else')
    Which is exactly as it should be. I copy and paste the exact
    same query into the database and it produces results - but when
    coldfusion runs the query it doesn't. Running the query with no
    quotes produces a sql error, which is what I wopuld expect.
    Which leaves me somewhat at a loss. Anyone got any ideas?
    Running CF 6.1 (I think) using a MySQL database, if that
    makes any difference to anything.

    That's with double single quotes around each of the strings,
    even though this wasn't specified in the variable sql_var.
    In Coldfusion, 'something' and "something" are the same
    thing. You should expect that Coldfusion could switch from one to
    the other.
    Where variable sql_var only has single quotes in between the two
    strings, and I've added single quotes to the select statement. This
    produces no error, but no results either. The sql being run is
    select id from table where somename in
    ('something','something else')
    I don't think that is the query being run. Before passing the
    string, "something','something else", to the query Coldfusion will
    automatically escape the single-quotes on either side of the comma.
    That is the default behaviour. The resulting query is
    select id from table where somename in
    ('something'',''something else')
    To avoid these complications, use the function
    PreserveSingleQuotes(). Thus,
    <cfset sql_var = "'something','something else'">
    <cfquery name="test" datasource="db">
    select id from table where somename in
    (#preservesinglequotes(sql_var)#)
    </cfquery>

  • Problem using DECODE() function with a Query of Queries

    I
    posted
    on my blog about an issue I was having trying to use the PL/SQL
    DECODE() function with a Coldfusion Query of Queries. This function
    works fine when you query a database for information. However, when
    you query another query, it seems that CF doesn't recognize it. I
    got errors stating that it found a left parenthesis where it
    expected a FROM key word. Here is a simplified version of what I am
    trying to do:
    quote:
    <!--- Simulated query; similar to what I was calling from
    my database --->
    <cfscript>
    qOriginal = queryNew("Name,Email,CountryCode",
    "VarChar,VarChar,VarChar");
    newRow = queryAddRow(qOriginal, 5);
    querySetCell(qOriginal, "Name", "Joe", 1);
    querySetCell(qOriginal, "Email", "[email protected]", 1);
    querySetCell(qOriginal, "CountryCode", "AMER", 1);
    querySetCell(qOriginal, "Name", "Sally", 2);
    querySetCell(qOriginal, "Email", "[email protected]", 2);
    querySetCell(qOriginal, "CountryCode", "AMER", 2);
    querySetCell(qOriginal, "Name", "Bob", 3);
    querySetCell(qOriginal, "Email", "[email protected]", 3);
    querySetCell(qOriginal, "CountryCode", "ASIA", 3);
    querySetCell(qOriginal, "Name", "Mary", 4);
    querySetCell(qOriginal, "Email", "[email protected]", 4);
    querySetCell(qOriginal, "CountryCode", "EURO", 4);
    querySetCell(qOriginal, "Name", "John", 5);
    querySetCell(qOriginal, "Email", "[email protected]", 5);
    querySetCell(qOriginal, "CountryCode", "EURO", 5);
    </cfscript>
    <cfquery name="qCountries" dbtype="query">
    SELECT DISTINCT(CountryCode) AS CountryCode,
    DECODE(states, "AMER", "North America &amp; Canada",
    "EURO", "Europe &amp; Africa", "ASIA", "Japan &amp;
    Asia","") CountryName
    FROM qOriginal
    ORDER BY CountryCode
    </cfquery>
    <cfdump var="#qCountries#">
    <!--- ========== END OF CODE ========== --->
    So running this returned the following error:
    Query Of Queries syntax error.
    Encountered "(. Incorrect Select Statement, Expecting a
    'FROM', but encountered '(' instead, A select statement should have
    a 'FROM' construct.
    Does anybody know why this doesn't work? Is it just not
    supported? Please note that I have also tried to use the CASE()
    function instead of DECODE() and that resulted in basically the
    same error. For now I an looping over my distinct query with a
    switch statement and manually loading a new query with the data how
    I want it. But it would be a lot cleaner and less code to have the
    DECODE() to work. Thx!

    DECODE() is an Oracle function, not generic SQL. Q-of-Q is a
    very limited subset of SQL and lacks many functions and clauses
    available in standard SQL, especially what you may be used to using
    in your particular RDBMS.
    See
    Query
    of Queries user guide
    Phil

  • Can't find answer to Query Of Queries runtime error

    Not only I browsed this forum but also googled this problem but unfortunnately I have no luck in finding the answer.
    All I did was writing this simple query:
    <cfquery name="test" dbtype="query">
    select SSN,BirthDate from myquery where SSN <> '' OR BirthDate <> ''
    </cfquery>
    and I got this error:
    Query Of Queries runtime error.
    Comparison exception while executing <>.
    Unsupported Type Comparison Exception: The <> operator does not support comparison between the following types:
    Left hand side expression type = "DOUBLE".
    Right hand side expression type = "STRING".
    I tried the following and did not work either, still got the same error.
    <cfquery name="test" dbtype="query"> 
    select SSN,BirthDate from myquery
    where SSN <> <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value=""/>  
    OR BirthDate <> <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value=""/></cfquery>
    Has someone ever encountered the same problem and know how to solve it?

    HELP ! ! !  Going into testing soon. I need this to work to get correct report results ! ! ! !
    My issue seems similar to the one under discussion and the reply from lawhite01 caught my eye. Can you roll my issue into this discussion?
    This is a 2 parter. The second part is the QoQ part, but the 1st part has a line in the query that is similar to the QoQ one and it uses the same data. Part 1 also throws an error.
    PART # 1.
    I'm trying to use a query table created through QueryNew and then query it.
    I need multiple columns in the query table I create:
    <cfscript>
            tot_AllCurrentDraftListing = QueryNew("AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS, JP_KW_1, JP_JobTitle, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaName, JP_AreaID, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_sal_low1, JP_sal_high1, JP_Grade2, JP_sal_low2, JP_sal_high2, JP_Grade3, JP_sal_low3, JP_sal_high3, JP_Grade4, JP_sal_low4, JP_sal_high4, JP_Grade5, JP_sal_low5, JP_sal_high5, JP_Posted, JP_TypeHire, JP_HRemail");
        </cfscript>
    Then I populate all the cells of the query table.
    Then I set up to use the created query table.
    I do this first:
        <cfquery name="qAltPostID" datasource="#at_datasource#">
             SELECT AltPoster, fk_Job_AnnounceNum
             from JOB_JPContacts
             Where AltJPContactType = 'AltPosterID'
             and AltPoster = '#session.IHSUID#'
             </cfquery>
    Then, in my first query using the created query, I expect to need to choose from multiple values, so I'm using this line in the query (this is NOT a QoQ query):
                and AnnounceNum IN (<cfqueryparam cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
    I've also tried:
                   and AnnounceNum IN (#ValueList(qAltPostID.fk_Job_AnnounceNum)#)   
    and:
                   and JOB_AnnounceNum IN
                    SELECT fk_Job_AnnounceNum
                    from JOB_JPContacts
                    Where AltJPContactType = 'AltPosterID'
                    and AltPoster = '#session.IHSUID#'
    ERROR is: one record should return. I get 0.
    PART # 2: Here's the QoQ part.
    I get the error:
    Query Of Queries runtime error.
    Comparison exception while executing IN.
    Unsupported Type Comparison Exception: The IN operator does not support comparison between the following types:
    Left hand side expression type = "LONG".
    Right hand side expression type = "STRING".
    A tutorial I found gave an example using only one column for this part of the fix:
         tot_AllCurrentDraftListing = QueryNew("AnnounceNum", "CF_SQL_VARCHAR")
    How would I set up the query with the datatype when I'm using multiple columns:
    <cfscript>
            tot_AllCurrentDraftListing = QueryNew("AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS, JP_KW_1, JP_JobTitle, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaName, JP_AreaID, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_sal_low1, JP_sal_high1, JP_Grade2, JP_sal_low2, JP_sal_high2, JP_Grade3, JP_sal_low3, JP_sal_high3, JP_Grade4, JP_sal_low4, JP_sal_high4, JP_Grade5, JP_sal_low5, JP_sal_high5, JP_Posted, JP_TypeHire, JP_HRemail");
        </cfscript>
    I used this code after all the cells contained values and before running my QoQ query:
            <cfloop index="intID" from="1" to="#tot_AllCurrentDraftListing.recordcount#" step="1">
                <cfset tot_AllCurrentDraftListing["AnnounceNum"] [intID] = JavaCast("string", intID) />
            </cfloop>
              Is that correct?
    Thanks.
    Whoever can help me with this should be awarded extra points ! ! ! !

  • Query of queries problem or bug

    Hello Everyone,
    I have used cfdirectory to get a list of files. As the result
    I receive query with the files.
    Then I want to search it using query of queries. I' ve found
    a problem and I wonder if it is a bug of Coldfusion or perhaps
    wrong usage of QoQ. The thing is that the files that I have are
    using '_' and then are followed by number of week. It seems that
    searching something like this '%_6' returns results *_*6. See
    attached code.
    Thanks for all answers in advance.

    > I think you'll find "_" is a single-char wildcard when
    used with the LIKE
    > operator.
    Found out how to escape it:
    WHERE Name LIKE '%[_]6%'
    I'm glad you brought this up... I didn't know about this
    until I looked @
    your issue. That's my new thing learned for the day: I can go
    to the pub
    now ;-)
    Adam

  • Query of Queries problem

    Over the past several weeks we've been experiencing periodic
    hangs of the ColdFusion service. We finally invested in SeeFusion
    and found the problem, but aren't sure how to fix it
    The code that hangs is a query of queries block. Basically we
    are getting a result set from verity (~1000 rows), then getting a
    result set from SQL server (~3000 rows), and joining the two with
    the query of query statement. Everything will run fine for a few
    hours, then that block of code will bog down. When I dumped the
    threads during the error, everything gets hung like so:
    "jrpp-255" runnable
    at
    coldfusion.sql.imq.rttExpr.guesstimateJavaType(rttExpr.java:439)
    at
    coldfusion.sql.imq.rttExpr.guesstimateJavaType(rttExpr.java:371)
    at
    coldfusion.sql.imq.imqTable.guessColumnType(imqTable.java:443)
    at
    coldfusion.sql.QueryTableMetaData.InferMetaDataTypes(QueryTableMetaData.java:350)
    at coldfusion.sql.imq.TableList.validate(TableList.java:166)
    at
    coldfusion.sql.imq.rttSelectExprSpec.validate(rttSelectExprSpec.java:498)
    at
    coldfusion.sql.imq.rttSelectStmt.validate(rttSelectStmt.java:84)
    at
    coldfusion.sql.imq.jdbcStatement.fetchResult(jdbcStatement.java:538)
    at
    coldfusion.sql.imq.jdbcStatement.execute(jdbcStatement.java:131)
    at coldfusion.sql.Executive.executeQuery(Executive.java:775)
    at coldfusion.sql.SqlImpl.execute(SqlImpl.java:240)
    at
    coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:500)
    at
    cfauctionManagement2ecfc978963305$funcJOINAUCTIONSTOVERITY.runFunction(D:\inetpub\wwwroot \CustomTags\mysite\component\auctionManagement.cfc:137)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344)
    at
    coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at
    coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:290)
    at
    coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:254)
    at
    coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56)
    at
    coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:366)
    at
    coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:198)
    at
    coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:157)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:1594)
    at
    coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:341)
    at
    cfact_search_auctions2ecfm1040202400._factor47(D:\inetpub\wwwroot\CustomTags\mysite\actio n\act_search_auctions.cfm:849)
    at
    cfact_search_auctions2ecfm1040202400.runPage(D:\inetpub\wwwroot\CustomTags\mysite\action\ act_search_auctions.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.filter.CFVariablesScopeFilter.invoke(CFVariablesScopeFilter.java:63)
    at
    coldfusion.tagext.lang.ModuleTag.doStartTag(ModuleTag.java:255)
    at
    coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:1925)
    at
    cfindex2ecfm1952396859.runPage(D:\inetpub\wwwroot\mysite\cfml\auctions\index.cfm:18)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
    at
    coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
    at
    cflas2dvegas2dtimeshares2ecfm1477369516.runPage(D:\inetpub\wwwroot\mysite\cfml\las-vegas- timeshares.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
    at
    coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
    ...etc
    I believe this means CF is trying to "guesstimate" the java
    type of each column in the result set. We tried to work around that
    by CASTing each column as a varchar, but we still have the same
    issue.
    If anyone has an idea what the problem could be, we'd really
    appreciate any help. Also, if anyone can suggest a way to merge the
    two result sets without using SQL, that would be great too. I've
    already tried nested loops to manually build the final result set,
    but that was taking up to 5 seconds to run.
    Environment:
    CFMX 7.0.2
    Win2K
    SQL Server 2K

    > We need more information than that to display a record,
    so we select
    > everything out of the database (which is fairly quick),
    then JOIN that to the
    > verity results (WHERE auctionID = KEY).
    Right. And what do you need THOUSANDS of matches for, in one
    hit, here?
    And what do you need ALL those columns for, when dealing with
    all these
    thousands of rows. You've not really answered my question as
    to "what's
    the end result here?" What are you trying to achieve? I don't
    mean what
    you're doing to aggregate the data, but simply *why*? What is
    the
    requirement you have here to be engaging in this enterprise
    in the first
    place? Search screen? Stock control report? What?
    Is there any way of optimising how much processing you're
    doing?
    If - say - you're doing a search results screen, you probably
    don't need
    1000s of results: you probably need 20. So just ask the DB
    for 20: WHERE
    id IN (#list of 20 IDs from Verity search results#)
    If the user goes "NEXT >>", then grab the next 20
    (cache the Verity query
    somehow, rather than re-query it).
    Obviously there's some heavy-lifting processing that might
    need to process
    the whole lot. Can this not be done in a sliding window of
    results? Or
    could you not pass the list of IDs from the Verity resultset
    into the DB
    somehow, and do the filtering on the DB engine, rather than
    with CF (which
    is not very good at bulk data processing, as you're seeing.
    It's not what
    it's designed for).
    I find QoQ to be very flaky for all ut the most basic
    operations. For
    basic stuff it's fine. It does not surprise me that it seems
    to leak
    memory (or whatever it's doing) and eventually give up the
    ghost. This
    does not help you, I realise, but as a suggested practice:
    don't expect too
    much out of QoQ. Try some other method instead.
    Adam

  • A strange query of queries bug in CF11?

    Hi,
    I have this strange query of queries result that could be a bug in CF11.  The result is fine in CF10.
    Basically, I have 2 queries, qrA and qrB.  I do a join of the two in joinQr, after which I do a query of qrA.  Since I didn't alter qrA in any way, I would expect newQrA to give me the same result as qrA.  However it only gives me one row ("D").  Now, here's the strange thing:  If I start off qrA with the letters in ascending order ["A", "B", "C", "D"], then newQrA gives me the right result.
    <cfset qrA = queryNew("")>
    <cfset queryAddColumn( qrA, "size", "varchar", [ "D", "A", "B", "C" ] )>
    <cfset qrB = queryNew("")>
    <cfset queryAddColumn( qrB, "size", "varchar", [ "A" ] )>
    <cfset queryAddColumn( qrB, "quantity", "integer", [ 0 ] )>
    <cfquery name="joinQr" dbtype="query">
        select qrA.*, qrB.quantity
        from qrA, qrB
        where qrA.size = qrB.size
    </cfquery>
    <cfquery name="newQrA" dbtype="query">
        select *
        from qrA
    </cfquery>
    <cfdump var="#qrA#">
    <cfdump var="#qrB#">
    <cfdump var="#joinQr#">
    <cfdump var="#newQrA#">

    For your interest, by coincidence, my first test was with
    <cfset queryAddColumn( qrA, "size", "varchar", [ "A","B","C","D" ] )> 
    It turns out that the order "A","B","C","D" works, whereas "D","A","B","C" fails. Quite funny, really.

  • Search Results Query Text - Get all data, Exclude all list data except one

    Hi Experts,
    I have a situation wherein in the global search of our internal site, we have to display all results & restrict any list item except one list. Earlier we had restricted /Lists/ & People to be displayed in the results.
    But in the new search results I have to display results from only one list along with other results (documents, sites, pages etc).
    Below is the original query text entered in the Search Results Query Text editor
    {searchboxquery} -contentclass:STS_List_Links  
    -filename:allitems.aspx  -Path:/articles/Pages/default.aspx
    -filename:DispForm.aspx  -Path:/Lists/ -Path:person.aspx
    I have tried various different queries with AND, OR operator. I have researched other blogs, sites over google. But unsuccessful. I am sure this is not a rare requirement. Need your expert help.
    I have tried this query also...
    {searchboxquery} (-filename:allitems.aspx -Path:/articles/Pages/ -Path:/Lists/ -Path:/PublishingImages/) OR
    (+(+Path: /Lists/ArticleContent/ AND +filename:*.aspx) AND
    -(-Path: */Lists/* OR -filename:*.aspx))
    Vighnesh Bendre
    MCTS
    http://markviky.blogspot.com

    Vighnesh,
    You should have success using the following:
    {searchboxquery} -contentclass:STS_List_Links -filename:allitems.aspx  -Path:/articles/Pages/default.aspx -Path:person.aspx ((-filename:DispForm.aspx  -Path:/Lists/) OR Path:/Lists/ArticleContent/)
    Two things from your original query were excluding list items from your results, your exclusion of file
    DispForm.aspx and path Lists.  By using "OR" in the above query, we're creating an exception to also allow items under
    Lists/ArticleContent to be included in the results.

  • Display combined results of 2 queries in 1 BEx Web Report.

    Dear Experts
    I tried to achieve this in just 1 BEx Query and found it difficult.
    Then I ended up creating 2 BEx Queries getting partial result and then amalgamating both in WAD. Still I think there should be a way to achieve what I need from just 1 BEx Query. Below is what I am trying to achieve:
    Query 1:
    Overall Result is the Total Number of Invoices restricted by 2 values.
    Credit Invoices is the Total Number of Invoices restricted by 1 value.
    % of Credits over Total Invoices = Credit Invoices / Overall Result
    Query 2:
    I have created a Condition on 'Reason Codes' to pick on the Top N (3 in this case) to display the values in %.
    All the CHARs and KEYFs are in the Rows Column only for both the Queries at the moment. When I am trying to amalgamate both into 1 BEx Query, the Query is throwing up errors and Execution is falling over. Another issue here is, there are 3 Reason Codes in the Third Place when I checked in ListCube and don't know what needs to be done. I am planning to discuss this with the Business Users if this should be extended to Top 5 instead of Top 3. Any ideas..!
    Users want to see the final report only in Web Analyzer as they do currently (so BEx Analyzer & Workbook are out of question). But I will be using Web Templates eventually to bring together 8 (it will be 9 if this report can't be done in 1 BEx Query) BEx Reports.
    How can I achieve this in just 1 BEx Query?
    Thanks for your time in advance.
    Kind regards,
    Chandu

    Hi Suman
    Thanks for your reply. When I am having both the parts of Query 1 & Query 2, the BEx Report is falling over when executed pointing to Condition.
    The second Query will pick the Top 3 Reason Codes for a particular Customer and then the individual Document Count for these 3 Reason Codes is divided by the Overall Result (Document Count) to give the individual Result across each row as %.
    Hope this is clear now. I tried Cell Definitions but didn't find it useful in this scenario, or I might be missing something. Can you please explain me in detail of how this can be done in 1 BEx Query using Cell Def?
    Please let me know if this can be achieved in Single BEx Query.
    Thanks,
    Chandu

  • Combining result of three queries to form a single table

    Hi ..
    I have three select queries. Each of them returns a single column. I want the result of these queries into a single table..
    I tried this way..
    select * from
    (first select),(second select),(third select);
    this gives duplicate rows... Any held would be appreciated

    Hi,
    Welcome to the forum!
    1005370 wrote:
    Hi ..
    I have three select queries. Each of them returns a single column. I want the result of these queries into a single table..Remember that the people who want to help you don't know as much about your tales and your application as you do; in fact, they might not know anything at all about them.
    You might ask a friend: "How can I get to that restaurant we went to last week?", and expect to get a good answer, because your friend knows where you are starting from, and knows, from that brief description, where you want to go. But would you expect a stranger on the internet to answer the exact same question? Of course not! A stranger on the internet wouldn't know where you're starting from, or where you want to go. How could a stranger give you directions with only that information?
    SQL code is like directions. A SQL query can tell you how to get a certain result set from a certain sample data set. No matter how well someone knows SQL, they need to know something about the data in a problem and the results needed fom that data before they can start writing a query to get those results from that data.
    Whenever you have a question, you need to post a little sample data (CREATE TABLE and INSERT statements) for all tables involved, and the results you want from that data in this case, the contents of the new table).
    All this and more is in the forum FAQ {message:id=9360002}. Take a few minutes now to read that page. It can realy help you get better results faster on this forum.
    I tried this way..
    select * from
    (first select),(second select),(third select);
    this gives duplicate rows... Any held would be appreciatedIf duplicate rows are the only problem, then just add DISTNCT t the main SELECT clause:
    select DISTINCT  *
    from    (first select)
    ,     (second select)
    ,     (third select)
    ;However, I'll bet duplicate rows aren't really the problem. It's much more likely that the problem is duplicate values in just 1 column.
    Again, how to get the output you want from your data depends on your data and the output you want. Post CREATE TABLE and INSERT statements for some sample data, and the complete results you want from that data. Explain how you get those results from that data.

  • Query of queries disallows SQL right() function

    We're attempting to do a query of queries using the SQL
    right() function like this:
    select *
    from getresults
    where right([key],charindex('\',reverse([key]),1)-1) not in
    (#quotedvaluelist(getexcluded.file_name)#)
    We've even replaced that where clause with a much more simple
    where right([key])='m'
    just to make sure that it wasn't the nesting functions that
    were causing the problem.
    In either case, we get the error:
    Query of Queries syntax error.
    Encountered "right" at line 0, column 0. Incorrect
    conditional expression,
    Expected one of [like|null|between|in|comparison] condition,
    What SQL functions are disallowed from query of queries?
    Thanks,
    Kris

    Nasty stuff huh. Just happened to discover myself today that
    Left doesn't work. I'd suspect that Aggregate functions are the
    ONLY ones that will work. It would have been nice if they'd at
    least allowed CF vs DB functions in their own "database" language.
    BTW, also discovered that Count() returns Null rather than 0
    when there aren't any per your WHERE clause.

  • Query Of Queries : Error When Trying To Fake Left Outer Join

    Hi there
    I am trying to replicate a left outer join, combining two query of queries using a method I located here
    However, I keep getting an error message..
    Here is the code I am using....
        <cfquery dbtype="query" name="qry">
                    SELECT *
                    FROM returnQry, returnQry2
                    WHERE returnQry.mediumImage = returnQry2.mediumImage
                    ORDER BY returnQry.name   
                </cfquery>
                <cfquery name="returnQry3" dbtype="#application.mx#">
                    SELECT *
                    FROM trackmeanings AS t
                </cfquery>      
               <cfquery dbtype="query" name="endQry">
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE qry.name = returnQry3.sNameTrack
                    UNION
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE #qry.name# NOT IN (#QuotedValueList(returnQry3.sNameTrack)#)
                    GROUP BY name,nameRcd,mediumImage
                </cfquery>
    When I try to use the query output in a page, i get the error message "Incorrect conditional expression,  Expected one of [like|null|between|in|comparison] condition"
    Would anyone have any ideas?
    Many thanks

    Actually , spoke a little too soon, my query now seems to be outputting duplicates when the value is found on both sides of the union, my group by clause doesnt seem to be eliminating them like it usually does.
    My SELECT code now reads
    <cfquery dbtype="query" name="endQry">
    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
    FROM qry, returnQry3
    WHERE qry.name = returnQry3.sNameTrack
    GROUP BY name,nameRcd,mediumImage
    UNION
    SELECT name,nameRcd,mediumImage, 0 AS comments
    FROM qry
    WHERE qry.name NOT IN (<cfqueryparam
    value="#returnQry3.sNameTrack#"
    cfsqltype="cf_sql_varchar"
    list="yes"
    />)
    GROUP BY name,nameRcd,mediumImage
    ORDER BY name DESC
    </cfquery>
    and my ouput...is producing duplicates
    <cfoutput query="rc.qryTopTracks" group="name">
    #rc.qryTopTracks.name#
    </cfoutput>
    Would you have any idea of how to eliminate them here?  Thanks

  • Query Of Queries syntax error.

    Hi all,
    I have the following query:
    <cfquery name="agent" datasource="datasourcename">
    SELECT * FROM quotes where status = 'Pending'
    <cfif isDefined("form.agent")>
    AND agent = '#FORM.agent#'
    </cfif>
    </cfquery>
    Then, I have the following query of that query
    <cfquery name="totalvalue" dbtype="query">
    SELECT SUM(value) as total FROM agent
    </cfquery>
    however I get the following error:
    Query Of Queries syntax error.
    Encountered "SUM ( value. Incorrect Select List,
    on line 20 which is:
    <cfquery name="totalvalue" dbtype="query">
    now i'm sure this is identical to what ive used before but
    getting the error. the totals query works fine when querying the
    database direct, only got this error when I changed it to query the
    master query.
    i appreciate any help in advance, as no matter how much i
    stare at it I can't see whats wrong!

    I believe that
    value is a reserved word that is probably causing your
    current error. I would rename this column, or alias it in your
    original query. Also, I would add WHERE value IS NOT NULL to your
    Q-of-Q to cover your NULLs.
    Phil

  • Union in Query of Queries

    The attached code is an extract from a function I am writing,
    but is generating the following error...
    quote:
    All resulting columns of queries in a SELECT statement
    containing a UNION operator must have corresponding types.
    Columns with index number equal "4" have diffent types (DATE,
    VARCHAR).
    I have tried it without the type definitions in
    the QueryNew, but that doesn't help.
    The Operate function currently does nothing other than
    populate the RowCount and Revenue columns with zero (eventually it
    will do more stuff).
    The Clone function simply creates an array filled with the
    first variable the length of the second variable.
    Any ideas on how to fix it would be greatly appreciated.
    (Using CFMX7.0.1)
    --- code starts ---

    (Have solved it by looping instead, but it'd be nice if I
    could get the more elegant UNION to work.)

Maybe you are looking for

  • Emails don´t appear in phone´s inbox (only in subf...

    I run nokia messaging on e71 and synch with gmail. Many (gmail labeled) emails don´t appear in the phone´s inbox, but I have to navigate to the subfolder "all mail" to see them. Certainly, they appear in my gmail inbox just normally. Also, I am not a

  • Free subscription, but not in Newsstand?

    I have just successfully managed to make a subscription viewer with a free subscription, entered all info on Itunes Connect etc, but now I see this message on iTunes connect: Your first free In-App Purchase subscription(s) must be submitted with a ne

  • Automator Copy Finder Problem

    I just used automator for the 1st time so please bare with me... I want to make a backup of a directory located in another computer in my LAN, so I created a workflow in automator using *Get Specified Items* and then *Copy Finder Items*. The first Ru

  • How to change the way VLC starts up

    I have installed VLC via pacman, I would simply like to change it so it runs all the time with vlc --control lirc For example I have changed it in thunar when I open video files, it's fine, but some programs call the binary itself automatically (like

  • Query for xml:id fails

    Hello, I have a problem querying for the id-Attribute. I guess the solution is simple but I just don't get it %). Could someone give me a hint on that? Xml-Snippet <s xml:id="s100" n="s99"/> I can successfully query the document for the sentence //s[