CAML Query with 10 AND conditions
Hello,
I need some help with a CAML query. This particular query needs to have 10 AND conditions. Quite frankly, with all the nesting it is driving me a little nuts:
What I have is:
<Query>
<Where>
<And>
<And>
<And>
<And>
<And>
<And>
<And>
<And>
<And>
<Eq><FieldRef Name='Column1' LookupId='TRUE' /><Value Type='Text'>10341</Value></Eq>
<Eq><FieldRef Name='Column2' LookupId='TRUE' /><Value Type='Text'>9539</Value></Eq>
</And>
<Eq><FieldRef Name='Column3' LookupId='TRUE' /><Value Type='Text'>183</Value></Eq>
</And>
<Eq><FieldRef Name='Column4' LookupId='TRUE' /><Value Type='Text'>35</Value></Eq>
</And>
<IsNull><FieldRef Name='Column5' /></IsNull>
</And>
<Eq><FieldRef Name='Column6' LookupId='TRUE' /><Value Type='Text'>4387</Value></Eq>
</And>
<Eq><FieldRef Name='Column7' LookupId='TRUE' /><Value Type='Text'>4204</Value></Eq>
</And>
<Eq><FieldRef Name='Column8' LookupId='TRUE' /><Value Type='Text'>36</Value></Eq>
</And>
<Eq><FieldRef Name='Column9' LookupId='TRUE' /><Value Type='Text'>213</Value></Eq>
</And>
<IsNull><FieldRef Name='Column10' /></IsNull>
</And>
</Where>
</Query>
I have added this into my ItemAdding Event Receiver as it will basically do a check for duplicate items based on the 10 columns.
If anyone can help guide me in this, it would be much appreciated. I have been using a CAML Query Builder to help.
http://webcache.googleusercontent.com/search?q=cache:xji7jOxa5_EJ:aasai-sharepoint.blogspot.com/2013/02/caml-query-with-multiple-conditions.html+&cd=3&hl=en&ct=clnk&gl=in
http://stackoverflow.com/questions/6203821/caml-query-with-nested-ands-and-ors-for-multiple-fields
Since you are not allowed to put more than two conditions in one condition group (And | Or) you have to create an extra nested group (MSDN). The expression
A AND B AND C looks like this:
<And>
A
<And>
B
C
</And>
</And>
Your SQL like sample translated to CAML (hopefully with matching XML tags ;) ):
<Where>
<And>
<Or>
<Eq>
<FieldRef Name='FirstName' />
<Value Type='Text'>John</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name='LastName' />
<Value Type='Text'>John</Value>
</Eq>
<Eq>
<FieldRef Name='Profile' />
<Value Type='Text'>John</Value>
</Eq>
</Or>
</Or>
<And>
<Or>
<Eq>
<FieldRef Name='FirstName' />
<Value Type='Text'>Doe</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name='LastName' />
<Value Type='Text'>Doe</Value>
</Eq>
<Eq>
<FieldRef Name='Profile' />
<Value Type='Text'>Doe</Value>
</Eq>
</Or>
If this helped you resolve your issue, please mark it Answered
Similar Messages
-
SQL Query clauses and conditions
Hi,
I wanna to get the entire conditions specified in the SQL query to do a specific treatement on them.
in fact, i want to do a syntaxical analyse on the query.
If there is a specific table where query in stored is seperate clauses, objects invoked, conditions used,..., please let me know.
elsewhere, il you have a PL/SQL program that do that, it'll be wonderfull.
Best regards;thank for your reply, but what i need is not the query text, but the seperated query clauses and conditions.
best regards -
Query with a condition - Overall results row displays incorrect value
Hi All,
I have a bw query with top 40 conditions. However, The Overall Result Row Figures Do Not Equal The Sum of the Column Rows.
Although the top condition is activated, the overall result still displays the overall result of the whole report.
I have 3 columns in the report
Selected Period
Prior Period and
Variance
The formula for variance is (Selected Period/Prior Period)-1.
Does anyone have an idea to fix this?
Thank you so much in advance.
Have a great day!Hi Gaurav,
Thank you so much for your reply, however this does not solve fully the issue.
Changing the properties to "Summation" will indeed provide me with the correct sum for the "selected period" and "Prior Period." However what I need in the Overall Result Row for the "Variance" column is not the total but instead the value when the total of Selected Period is divided by Prior Period then minus 1.
Overall Variance = (Overall Selected Period/Overall Prior Period)-1
Do you know a way to make this possible.
Thank you so much. -
Empty WHERE Clause with AND condition after
I have a question concerning a SQL query that I am using for a report. I have converted an old report to Crystal Reports 2008 and the resulting SQL query no longer works.
After the conversion all the inner joins that were previously used in the report were moved to the FROM clause.
My resulting WHERE clause is as follows:
WHERE AND
"TABLE"."TABLEKEY" IS NOT NULL
I get this error message:
ORA-00936 Missing expression
As you can see there WHERE clause has nothing before the AND condition because all the inner joins have moved to the FROM clause in the new version of Crystal Reports. I am fine with these inner joins moving but how do I take care of this empty condition.
Any help is appreciated.Hi Joshua
Please go through the following SAP note which deals with similar type of issue.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313335333533393334%7D.do
Thanks -
CAML Query with Javascript value
Hey everyone,
I am building an Sharepoint 2013 app (SharePoint-Hosted) and using a CAML Query to get the current Item.
The Current Item ID is 1 and i stored it in AccountID, but i want that variable inserted in the CAML Query so i get the proper information.
var AccountID = 1
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=ID LookupId="TRUE"/><Value Type="Text">1</Value></Eq></Where></Query></View>');
But instead of putting the '1' value in the CAML Query, i want the variable AccountID in it... but how?
Already tried this, but that didn't work:
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=ID LookupId="TRUE"/><Value Type="Text">' + AccountID + '</Value></Eq></Where></Query></View>');
Can someone help me with this?
In forward, many thanks!Right, you have to use single quotes in a string literal inside double quotes. Just making sure it didn't have NO quotes, as your initial post showed.
Is the ID field actually a lookup field? Or is it just the built-in ID field of the list? If it isn't a field of TYPE Lookup, try this:
camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Number'>" + AccountID + "</Value></Eq></Where></Query></View>");
Danny Jessee
MCPD - SharePoint Developer 2010
MCTS - SharePoint 2010, Configuring
dannyjessee.com/blog -
URL data type in CAML Query with Client side object model
hi,
How do I write a CAML query to filter list items based on the URL field using it's Description?
Same with REST API. How do I construct a REST query so that filter list items based on the URL data type using it's Description.Hi Cooltechie,
Thanks for posting your query, Below are the example that you can use in your CAML query
<Where><Eq><FieldRef Name="FileRef"/><Value Type="Url">sites/SiteCollection/SubSite/Site Documents/Excel Report.xls</Value></Eq></Where>
Note: Do not include the server name or beginning /.
The following examples assuming you have a list or library setup with a URL column named "My Document".
The link is to a document that is hosted on the sharepoint server (do not need server name):
<Where><Eq><FieldRef Name="My_x0020_Document"/><Value Type="URL">/sites/subsite/Site%20Documents/Excel%20Report.xls</Value></Eq></Where>
The link is an absolute URL to something not on the server... for example http://www.google.com:
<Where><Eq><FieldRef Name="My_x0020_Document"/><Value Type="URL">http://www.google.com</Value></Eq></Where>
I hope this is helpful to you, mark it as Helpful.
If this works, Please mark it as Answered.
Regards,
Dharmendra Singh (MCPD-EA | MCTS)
Blog : http://sharepoint-community.net/profile/DharmendraSingh -
Question about caml query with UserID/ parameter (working outside of sharepoint )
I have to develop a custom view. I should take the current user and query it in List1 to obtain owned group names. Then I am supposed to query each group name in a List2 to obtain corresponding users. And In a new custom list view I should display those users..
Let's assume I'm working in a c# class in VS. Below is my initial code to fetche owned groups by the current user.
SPQuery query = new SPQuery();
query.ViewFields = @"<FieldRef Name='Title'/>";
query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Integer'><UserID/></Value></Eq></Where>";
SPList lstUsers = web.Lists["Users"];
SPListItemCollection userItems = lstUsers.GetItems(query);
foreach (SPListItem myitem in userItems)
{Response.Write(myitem["Title"].ToString());}
The "<UserID/>" parameter in caml query does not work outside...
query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Integer'><UserID/></Value></Eq></Where>";
How can I obtained the current logged user from outside of sharepoint?
Should I write my code somewhere other then a seperate vs c# class?
I appreciate any idea and suggestions....If you are quering a User ID of UserField, you need to add LookupId='True'/ to FieldRef
<Eq>
<FieldRef Name=Owner' LookupId='True'/>
<Value Type='User' >2</Value>
</Eq>
Thanks, Rocky Fernandes -
CAML Query with ECMA script, ORDERBY not working
Hi, I'm trying to get this CAML query to order by created date. Seems like no matter what I do, it shows me the oldest items first. Here's my code:
function retrieveListItemsInclude() {
var clientContext = new SP.ClientContext();
var oList = clientContext.get_web().get_lists().getByTitle('NewsItems');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Neq><FieldRef Name=\'Deleted\' /><Value Type=\'Integer\'>1</Value></Neq></Where><OrderBy><FieldRef Name=\'Created\' Ascending=\'FALSE\'/></OrderBy></Query><RowLimit>10</RowLimit><ViewFields><FieldRef
Name=\'Title\'/><FieldRef Name=\'Link\'/><FieldRef Name=\'Description\'/><FieldRef Name=\'PubDate\'/><FieldRef Name=\'Source\'/><FieldRef Name=\'Topics\'/><FieldRef Name=\'ImageTag\'/><FieldRef Name=\'ImageSource\'/><FieldRef
Name=\'Created\'/></ViewFields></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem, 'Include(Title, Link, Description, PubDate, Source, Topics, ImageTag, ImageSource, Created)');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
I tried ordering my ID, Created or Created_x0020_Date, and none of it changes the output at all.
As a related question, how do I debug this CAML query? Are there any tools?Hi,
Please change the CAML query as below:
<where><neq><fieldref name=\'Deleted\' /><value type=\'Number\'>1</value></neq></where>
The following code for your reference:
string siteURL = "http://siteURL/";
string listName = "CustomList";
ClientContext context = new ClientContext(siteURL);
//specific user
NetworkCredential credentials = new NetworkCredential("username", "password", "domain");
context.Credentials = credentials;
List oList = context.Web.Lists.GetByTitle(listName);
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<view><query><where><neq><fieldref name=\'Deleted\' /><value type=\'Number\'>1</value></neq></where><orderby><fieldref name=\'Created\' ascending=\'False\' /></orderby></query><rowlimit>10</rowlimit></view>";
ListItemCollection collListItem = oList.GetItems(camlQuery);
context.Load(collListItem);
context.ExecuteQuery();
foreach (ListItem oListItem in collListItem)
Console.WriteLine("ID: {0}", oListItem.Id);
If the issue still exists, please check the "Deleted" field type.
Here is a CAML query tool for your reference.
http://spcamlqueryhelper.codeplex.com/
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support -
To create query with selecting condition have AND options
Hi All ,
I want to create a query in SQ01 . I want to get data from a table whose one specific field have data starting with Z AND Z : * ( not OR )* . Is it possible to do any thing in the selection screen or i have to do any other change ?
Please help me in this.
Thanks & Regards ,
Sabu.Hi
Your select statment u can have
field in ( 'Z%' , 'Z:%')
you will get all fields starting with z and Z;
regards -
Hi,
I am trying to get a recordset that samples multiple columns of my Access database for filtering, rather than just one. I looked at a few .asp websites and they say the query would be written like this:
SELECT SystemName, SystemCategory, Branch, Manufacturer
FROM UnmmannedAircraftSystems
WHERE Branch LIKE %MMColParam%
AND PerfSensorPayloads LIKE %MMColParam2%
ORDER BY SystemName ASC
but it never works. The page fails on the server. And I know this type of query works through straight .asp coding, but somehow the way Dreamweaver sets up the variables is killing it.
Anybody have an ideas?
MW<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../Connections/BleahBleahBleahhhhh" -->
<%
Dim RSfilterRec__MMColParam
RSfilterRec__MMColParam = "1"
If (Request.Form("BranchesUsedby") <> "") Then
RSfilterRec__MMColParam = Request.Form("BranchesUsedby")
End If
%>
<%
Dim RSfilterRec__MMColParam2
RSfilterRec__MMColParam2 = "1"
If (Request.Form("SensorPay") <> "") Then
RSfilterRec__MMColParam2 = Request.Form("SensorPay")
End If
%>
<%
Dim RSfilterRec
Dim RSfilterRec_cmd
Dim RSfilterRec_numRows
Set RSfilterRec_cmd = Server.CreateObject ("ADODB.Command")
RSfilterRec_cmd.ActiveConnection = MM_ConnUASdata_STRING
RSfilterRec_cmd.CommandText = "SELECT SystemName, SystemCategory, Branch, Manufacturer FROM UnmannedAircraftSystems WHERE Branch LIKE ? AND PerfSensorsPayloads LIKE ? ORDER BY SystemName ASC"
RSfilterRec_cmd.Prepared = true
RSfilterRec_cmd.Parameters.Append RSfilterRec_cmd.CreateParameter("param1", 200, 1, 255, "%" + RSfilterRec__MMColParam + "%") ' adVarChar
RSfilterRec_cmd.Parameters.Append RSfilterRec_cmd.CreateParameter("param2", 200, 1, 255, "%" + RSfilterRec__MMColParam2 + "%") ' adVarChar
Set RSfilterRec = RSfilterRec_cmd.Execute
RSfilterRec_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
RSfilterRec_numRows = RSfilterRec_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
/* Tips for Elastic layouts
1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing.
.thrColEls #container {
width: 46em; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
/* Tips for sidebar1:
1. Be aware that if you set a font-size value on this div, the overall width of the div will be adjusted accordingly.
2. Since we are working in ems, it's best not to use padding on the sidebar itself. It will be added to the width for standards compliant browsers creating an unknown actual width.
3. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".thrColEls #sidebar1 p" rule.
.thrColEls #sidebar1 {
float: left;
width: 11em; /* since this element is floated, a width must be given */
background: #EBEBEB; /* top and bottom padding create visual space within this div */
height: 1200px;
padding-top: 15px;
padding-right: 0;
padding-bottom: 15px;
padding-left: 0;
.thrColEls #sidebar2 {
float: right;
width: 11em; /* since this element is floated, a width must be given */
background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 15px 0; /* top and bottom padding create visual space within this div */
height: 1200px;
.thrColEls #sidebar1 h3, .thrColEls #sidebar1 p, .thrColEls #sidebar2 p, .thrColEls #sidebar2 h3 {
margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
margin-right: 10px;
height: 100%;
/* Tips for mainContent:
1. If you give this #mainContent div a font-size value different than the #sidebar1 div, the margins of the #mainContent div will be based on its font-size and the width of the #sidebar1 div will be based on its font-size. You may wish to adjust the values of these divs.
2. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
3. To avoid float drop, you may need to test to determine the approximate maximum image/element size since this layout is based on the user's font sizing combined with the values you set. However, if the user has their browser font size set lower than normal, less space will be available in the #mainContent div than you may see on testing.
4. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs that may occur.
.thrColEls #mainContent {
margin: 0 12em 0 12em; /* the right margin can be given in ems or pixels. It creates the space down the right side of the page. */
/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 8px;
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
-->
</style><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.thrColEls #sidebar1, .thrColEls #sidebar2 { padding-top: 30px; }
.thrColEls #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>
<body class="thrColEls">
<div id="container">
<div id="sidebar1">
<h3> </h3>
<!-- end #sidebar1 --></div>
<div id="sidebar2">
<h3> </h3>
<!-- end #sidebar2 --></div>
<div id="mainContent">
<h1>
<table border="1">
<tr>
<td>ID</td>
<td>SystemName</td>
<td>SystemCategory</td>
<td>Branch</td>
<td>Manufacturer</td>
<td>Status</td>
<td>Inventory</td>
<td>PlatformCost</td>
<td>SystemCost</td>
<td>PlannedBuyToDate</td>
<td>PlannedBuyYear1</td>
<td>PlannedBuyYear1Quantity</td>
<td>PlannedBuyYear2</td>
<td>PlannedBuyYear2Quantity</td>
<td>PlannedBuyYear3</td>
<td>PlannedBuyYear3Quantity</td>
<td>PlannedBuyYear4</td>
<td>PlannedBuyYear4Quantity</td>
<td>PlannedBuyYear5</td>
<td>PlannedBuyYear5Quantity</td>
<td>PlannedBuyYear6</td>
<td>PlannedBuyYear6Quantity</td>
<td>PlannedBuyYear7</td>
<td>PlannedBuyYear7Quantity</td>
<td>PlannedBuyYear8</td>
<td>PlannedBuyYear8Quantity</td>
<td>PlaformOperationPicLink</td>
<td>OrthoDrawingLink</td>
<td>Capability</td>
<td>BackgroundSysDescrip</td>
<td>SystemDescription</td>
<td>CharLength</td>
<td>CharWingSpan</td>
<td>CharGrossWgt</td>
<td>CharPayloadWgt</td>
<td>CharEngines</td>
<td>CharFuelWgtType</td>
<td>DataLinks1</td>
<td>DataLinks2</td>
<td>DataLinks3</td>
<td>Frequencies1</td>
<td>Frequencies2</td>
<td>Frequencies3</td>
<td>PerfEndurance</td>
<td>PerfRadius</td>
<td>PerfCeiling</td>
<td>PerfAirspeeds</td>
<td>PerfTakeoff</td>
<td>PerfLanding</td>
<td>PerfSensorsPayloads</td>
<td>PerfSensorModels</td>
<td>PayloadCharInternalSize</td>
<td>PayloadCharInternalWgt</td>
<td>PayloadCharInternalPwr</td>
<td>PayloadCharInternalEnv</td>
<td>PayloadCharExternalSize</td>
<td>PayloadCharExternalWgt</td>
<td>PayloadCharExternalPwr</td>
<td>PayloadCharExternalEnv</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT RSfilterRec.EOF)) %>
<tr>
<td><%=(RSfilterRec.Fields.Item("ID").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("SystemName").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("SystemCategory").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Branch").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Manufacturer").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Status").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Inventory").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlatformCost").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("SystemCost").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyToDate").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear1").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear1Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear2").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear2Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear3").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear3Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear4").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear4Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear5").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear5Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear6").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear6Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear7").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear7Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear8").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlannedBuyYear8Quantity").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PlaformOperationPicLink").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("OrthoDrawingLink").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Capability").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("BackgroundSysDescrip").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("SystemDescription").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("CharLength").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("CharWingSpan").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("CharGrossWgt").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("CharPayloadWgt").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("CharEngines").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("CharFuelWgtType").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("DataLinks1").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("DataLinks2").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("DataLinks3").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Frequencies1").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Frequencies2").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("Frequencies3").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfEndurance").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfRadius").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfCeiling").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfAirspeeds").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfTakeoff").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfLanding").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfSensorsPayloads").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PerfSensorModels").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharInternalSize").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharInternalWgt").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharInternalPwr").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharInternalEnv").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharExternalSize").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharExternalWgt").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharExternalPwr").Value)%></td>
<td><%=(RSfilterRec.Fields.Item("PayloadCharExternalEnv").Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
RSfilterRec.MoveNext()
Wend
%>
</table>
</h1>
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<!-- end #container --></div>
</body>
</html>
<%
RSfilterRec.Close()
Set RSfilterRec = Nothing
%> -
Update Collection by Query rule and condition
Hi,
I have one collection called Windows 7 Machines.
I've added a Query that I made like this:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID
= SMS_R_System.ResourceID where SMS_G_System_OPERATING_SYSTEM.Caption like "% Windows 7 %"
And it's working.
What I want the collection to do, is to update membership so Members Count is based on clients that is actively communicating with the SCCM server, and exclude those who haven't communicated with the server for 40 days.GREAT NEWS :D I've managed to configure the Clients Status by following the previous guide that i posted from technet.
Now is the only challenge to complete the Query. As i wrote above :
I don't understand is where to put the "client = active" statement, i've tried like this but it gives me This query has a syntax error, Are you sure you want to save it? Yes / No
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID
= SMS_R_System.ResourceID where SMS_G_System_OPERATING_SYSTEM.Caption like "% Windows 7 %" client = active
Thank you very much for your time. -
Query with additional condition
select * from (select b.account, f.company from account a, company f
where f.company=b.company
and f.company_type='BIZ') where rownum<=10
So, these are two tables I am drawing data from. I also need to pull the data from the account table where there is no company information attached to it. In that case, b.company would be null and subsequently there would be no f.company or f.company_type. Any help mucho appreciated!!!!You need to do a outer join. Like this
select a.account
, f.company
from account a
left
join company f
on f.company= a.company
and f.company_type = 'BIZ';
The query you have posted is incorrect. You have used an alias b in your select column but there is no such alias. Also whats the deal with ROWNUM filter? -
Query with a condition - Overall results row is wrong
Hello,
I have a query that uses a condition. The query gives me the top 10 brands according to the Net Sales. The query itself runs fine. I just noticed however that the Overall Result row isn't giving me the correct number.
For example:
<b>BRAND NETSALES MARGIN %</b>
Brand1 $100 25%
Brand2 $60 10%
Brand3 $20 15%
<b>OVERALL RESULT $210 2%</b>
As you can see it does not add up or average correctly. This query has no macros or anything, it only uses a condition.
Any suggestions?
Thanks,
NickA workaround I have found is the manual directions in this OSS note: 572910
Anyone have any follow up?
Thanks.
Nick -
SQL query with multiple condition
Below is the sample table
ID RATE DATE ORGAMNT PAYAMOUNT
1 3.45 12/23/2012 23000.45 19060.23
2. 5.50 04/12/2013 45000.00 36000.54
3. 6.44 04/16/200 60000.00 20000.00
Select a table with highest rate, Orgamnt with Date closer to current date.with
data_table as
(select 11186 hnum,11607400 oma,to_date('2/1/2006','mm/dd/yyyy') fpay,5.51 irate,10580934.67 apb,'WELLS FARGO BANK NA' hname from dual union all
select 11188,4801800,to_date('9/1/2006','mm/dd/yyyy'),6.3,4326951.51,'PNC BANK, NATIONAL ASSOCIATION' hname from dual union all
select 11189,1236100,to_date('8/1/2006','mm/dd/yyyy'),6.15,1147108.9,'HEARTLAND BANK' hname from dual union all
select 11192,1578400,to_date('4/1/2007','mm/dd/yyyy'),5.82,1470926.86,'WELLS FARGO BANK NA' hname from dual union all
select 11193,8150400,to_date('12/1/2008','mm/dd/yyyy'),6.75,7828776.28,'OPPENHEIMER MULTIFAMILY HSG' hname from dual union all
select 11195,3898000,to_date('5/1/2009','mm/dd/yyyy'),6.5,3752154.96,'BERKADIA COMMERCIAL MORTGAGE' hname from dual union all
select 11196,8040000,to_date('6/1/2009','mm/dd/yyyy'),7,7775734.57,'OPPENHEIMER MULTIFAMILY HSG' hname from dual union all
select 11197,37315000,to_date('12/1/2009','mm/dd/yyyy'),5.5,35851362.87,'RED MORTGAGE CAPITAL LLC' hname from dual union all
select 11199,3824000,to_date('2/1/2010','mm/dd/yyyy'),5.25,3673760.35,'WALKER AND DUNLOP LLC' hname from dual union all
select 11200,26927000,to_date('7/1/2010','mm/dd/yyyy'),4.7,25186682.65,'OAK GROVE COMMERCIAL MORTGAGE' hname from dual union all
select 11201,7208600,to_date('10/1/2010','mm/dd/yyyy'),4.59,6949026.64,'BERKADIA COMMERCIAL MORTGAGE' hname from dual union all
select 11204,9300000,to_date('2/1/2011','mm/dd/yyyy'),3.41,8927064.51,'PNC BANK, NATIONAL ASSOCIATION' hname from dual union all
select 11205,5200000,to_date('2/1/2011','mm/dd/yyyy'),3.56,4997518.18,'LOVE FUNDING CORPORATION' hname from dual union all
select 11206,6800000,to_date('5/1/2011','mm/dd/yyyy'),3.88,6576635.57,'WELLS FARGO BANK NA' hname from dual union all
select 11208,12240000,to_date('8/1/2011','mm/dd/yyyy'),3.84,11879882.17,'WELLS FARGO BANK NA' hname from dual union all
select 11209,12911500,to_date('10/1/2011','mm/dd/yyyy'),3.55,12542199.51,'M AND T REALTY CAPITAL CORP' hname from dual union all
select 11210,9596900,to_date('7/1/2011','mm/dd/yyyy'),5.38,9323421.23,'LANCASTER POLLARD MORTGAGE' hname from dual union all
select 11211,19951600,to_date('9/1/2011','mm/dd/yyyy'),3.88,19393524.45,'DEUTSCHE BANK BERKSHIRE MORTGAGE' hname from dual union all
select 11183,4230000,to_date('4/1/2009','mm/dd/yyyy'),6.55,4069938.75,'BERKADIA COMMERCIAL MORTGAGE' hname from dual union all
select 11212,50475000,to_date('1/1/2013','mm/dd/yyyy'),2.37,49852632.51,'LOVE FUNDING CORPORATION' hname from dual union all
select 11213,5496000,to_date('5/1/2012','mm/dd/yyyy'),3.1,5377541.15,'WELLS FARGO BANK NA' hname from dual
select hnum,oma,fpay,irate,apb,hname,r_oma,r_irate,r_fpay,0.5 * r_oma + 0.3 * r_irate + 0.2 * r_fpay r
from (select hnum,oma,fpay,irate,apb,hname,
dense_rank() over (order by oma desc) r_oma,
dense_rank() over (order by irate desc) r_irate,
dense_rank() over (order by (sysdate - fpay)) r_fpay
from data_table
order by r
HNUM
OMA
FPAY
IRATE
APB
HNAME
R_OMA
R_IRATE
R_FPAY
R
11197
37315000
12/01/2009
5.5
35851362.87
RED MORTGAGE CAPITAL LLC
2
9
12
6.1
11212
50475000
01/01/2013
2.37
49852632.51
LOVE FUNDING CORPORATION
1
20
1
6.7
11211
19951600
09/01/2011
3.88
19393524.45
DEUTSCHE BANK BERKSHIRE MORTGAGE
4
14
4
7
11200
26927000
07/01/2010
4.7
25186682.65
OAK GROVE COMMERCIAL MORTGAGE
3
12
10
7.1
11209
12911500
10/01/2011
3.55
12542199.51
M AND T REALTY CAPITAL CORP
5
17
3
8.2
11210
9596900
07/01/2011
5.38
9323421.23
LANCASTER POLLARD MORTGAGE
8
10
6
8.2
11196
8040000
06/01/2009
7
7775734.57
OPPENHEIMER MULTIFAMILY HSG
11
1
13
8.4
11208
12240000
08/01/2011
3.84
11879882.17
WELLS FARGO BANK NA
6
15
5
8.5
11193
8150400
12/01/2008
6.75
7828776.28
OPPENHEIMER MULTIFAMILY HSG
10
2
16
8.8
11186
11607400
02/01/2006
5.51
10580934.67
WELLS FARGO BANK NA
7
8
20
9.9
11204
9300000
02/01/2011
3.41
8927064.51
PNC BANK, NATIONAL ASSOCIATION
9
18
8
11.5
11201
7208600
10/01/2010
4.59
6949026.64
BERKADIA COMMERCIAL MORTGAGE
12
13
9
11.7
11206
6800000
05/01/2011
3.88
6576635.57
WELLS FARGO BANK NA
13
14
7
12.1
11183
4230000
04/01/2009
6.55
4069938.75
BERKADIA COMMERCIAL MORTGAGE
17
3
15
12.4
11195
3898000
05/01/2009
6.5
3752154.96
BERKADIA COMMERCIAL MORTGAGE
18
4
14
13
11188
4801800
09/01/2006
6.3
4326951.51
PNC BANK, NATIONAL ASSOCIATION
16
5
18
13.1
11213
5496000
05/01/2012
3.1
5377541.15
WELLS FARGO BANK NA
14
19
2
13.1
11205
5200000
02/01/2011
3.56
4997518.18
LOVE FUNDING CORPORATION
15
16
8
13.9
11199
3824000
02/01/2010
5.25
3673760.35
WALKER AND DUNLOP LLC -
Problem executing a query with AND and OR statements
I have no idea what is the correct way to implement this part. If the user enters more than one keyword. Then I need to check it using the clause WHERE and AND in my sql statements. Obviously, the attempt I make below does not work. Here is the code, I appreciate the help:
import java.io.*;
import java.sql.*;
import java.util.*;
public class simpleTest {
public static void main(String[] args) throws IOException {
int rows = 0;
int count = 0;
int i = 0;
String[] wordList = new String[50];
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {System.out.println("No driver");}
try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/cop4610webs",
"root", "anatoly");
// Do something with the Connection
System.out.println("Enter a string: ");
String word = reader.readLine();
StringTokenizer words = new StringTokenizer(word);
while(words.hasMoreTokens())
wordList[count++] = words.nextToken();
System.out.println("Enter the logic");
String logic = reader.readLine();
Statement stmt = null;
ResultSet rs = null;
stmt = conn.createStatement();
if(logic.equalsIgnoreCase("exact"))
rs = stmt.executeQuery("SELECT pageName FROM pages WHERE pageContent ='"+word+"'");
ResultSetMetaData metaData = rs.getMetaData();
System.out.println("Results of SELECT");
rs.last(); //move to last row
rows = rs.getRow(); //check rows returned
System.out.println(rows);
rs.beforeFirst(); //move back to beginning
if(rows != 0)
rs.next();
System.out.println(rs.getObject(1) );
while ( rs.next() ) {
System.out.println(rs.getObject(1) );
else
if(logic.equalsIgnoreCase("all"))
while(i < count)
rs = stmt.executeQuery("SELECT pageName FROM pages WHERE pageContent ='"+wordList[i]+"'" + "AND" +"'"+wordList[i+1]+"'");
i++;
System.out.println("Results of SELECT");
rs.last(); //move to last row
rows = rs.getRow(); //check rows returned
System.out.println(rows);
rs.beforeFirst(); //move back to beginning
if(rows != 0)
rs.next();
System.out.println(rs.getObject(1) );
while ( rs.next() ) {
System.out.println(rs.getObject(1) );
rs.close();
} catch (SQLException ex) { // handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}rs = stmt.executeQuery("SELECT pageName FROM pages WHERE pageContent ='"+wordList[i]+"'" + "AND" +"'"+wordList[i+1]+"'");should be:
rs = stmt.executeQuery("SELECT pageName FROM pages WHERE pageContent ='"+wordList[i]+"'" + " AND " +"'"+wordList[i+1]+"'");(spaces around the "and")
Maybe you are looking for
-
Anybody else having problems with airplay with ios 5.1 on iphone 4s
So i bought an iphone 4s a few months back and it came with ios 5, i then tryed it with my airplay speakers and they kept cutting out so i googles about it and found there was a known problem with iphone 4s and airplay speakers. ios 5.0.1 then came o
-
Dreamweaver cs6 Language Problem.Please Help!
i intstalled cs6, but the language is German. i can't find English language pack anywhere. if you have english lang. pack please send it to my e-mail(only lang. files). [email protected]
-
Preview and space bar don't work for one subdirectory
i have a directory d:/gaikoku/portugal and when i try to look at an image in it, the image does not show up in the preview window and using the space bar does not enlarge the image. if i change "portugal" to "portugall" everything works, so clearly t
-
Can anyone send some docs about 0infoprovider?
hi all, I am trying to create a new multiprovider where the infoproviders are from 4 ods. i want to restict an ods using infoprovider? So can anyone send me some docs nor links. to my email id [email protected] regds hari
-
CUCM 9.1 last login message error
Hi, i am coming across an issue wehre AD user try to login CUCM admin and sees incorrect last logiin message. It shows last login from 1 Jan 1970. But if ccmadmin login it shows correct date and time for last login. attached are screenshots. Not su