<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tag 'query'</title><link>http://forums.asp.net/search/SearchResults.aspx?q=&amp;tag=query&amp;orTags=0&amp;o=DateDescending</link><description>Search results matching tag 'query'</description><dc:language>en-US</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Display Query Result</title><link>http://forums.asp.net/thread/3549959.aspx</link><pubDate>Sat, 05 Dec 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3549959</guid><dc:creator>Yoseph</dc:creator><description>&lt;p&gt;Does anyone know of a way to&amp;nbsp;display sql&amp;nbsp;query&amp;nbsp;result in a texbox?&amp;nbsp; I do not want to use anything like Gridview or anything else from data toolbox.&lt;/p&gt;
&lt;p&gt;This is the textbox which I will use:&lt;/p&gt;
&lt;p&gt;&amp;lt;asp:TextBox ID=&amp;quot;TextBox1&amp;quot; text= MyQueryResult runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Oracle - alternating values</title><link>http://forums.asp.net/thread/3548342.aspx</link><pubDate>Fri, 04 Dec 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3548342</guid><dc:creator>davidl</dc:creator><description>&lt;p&gt;This is more of a query question... how to I alternate values in a SELECT query, for example:&lt;/p&gt;
&lt;p&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;select &lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;* &lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;from&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; fruit f &lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; f.isripe = &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;Y&amp;#39; &lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;and &lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;f.type &lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;in&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; (&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;APPLE&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;ORANGE&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;I want the output to be like:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;APPLE&lt;br /&gt;ORANGE&lt;br /&gt;APPLE&lt;br /&gt;ORANGE&lt;br /&gt;APPLE&lt;br /&gt;ORANGE&lt;br /&gt;APPLE&lt;br /&gt;APPLE&lt;br /&gt;APPLE&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#008080" size="2"&gt;This seems to do the trick (though I am not sure why, explain plan shows a sort happening), but I want to avoid using UNION if at all possible?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;select &lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;rownum&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;, f.*&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;from&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; fruit f&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; f.isripe = &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;Y&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;and&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; f.type = &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;APPLE&amp;#39;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;union&lt;br /&gt;select &lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;rownum&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;, f.*&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;from&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; fruit f&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; f.isripe = &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;Y&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;and&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt; f.type = &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;#39;ORANGE&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font color="#000080" size="2"&gt;&lt;font color="#000080" size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080" size="2"&gt;Possible without using UNION, and using SQL alone?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080" size="2"&gt;Cheers,&lt;br /&gt;DGL&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080" size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Random display query works as query but not on the page - ASP.Net - Visual Studio</title><link>http://forums.asp.net/thread/3546443.aspx</link><pubDate>Thu, 03 Dec 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3546443</guid><dc:creator>teesel</dc:creator><description>&amp;nbsp;&lt;p&gt;Hi there I’m new to forum help so I hope can explain my
problem to the best of my ability.&lt;/p&gt;
&lt;p&gt;Basically I have a data list view which is connected to an
object data source. The object data source is a table adapter which has a query
init(buitl witht he query builder). The query is stated below and when run from the table adapter view(preview
data part), it does what I want, that is, displays the result from the chosen category
randomly by the product id (so with in a set category the product id are
displayed randomly), but when I place it in the web page it all ways is the
same, and upon refresh or revisiting the page it doesn’t change. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This is the query that is run&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SELECT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TOP 3 Categories.CategoryId, Categories.CategoryName, Products.ProductId, Products.ProductName, Products.CategoryId AS Expr1, Products.Price, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Products.Description, Products.Make, Products.CC, Products.Stroke, Products.[Road Style], Products.Link, Products.Random&lt;br /&gt;FROM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Categories INNER JOIN&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Products ON Categories.CategoryId = Products.CategoryId)&lt;br /&gt;WHERE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Products.CategoryId = ?)&lt;br /&gt;ORDER BY Rnd(Products.ProductId)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could some one please help me resolve this issue as its extremely
annoying as I know the query works, but in the page it doesn’t.&lt;/p&gt;
&lt;p&gt;I’m using ASP.NET and c# as the background programming language
if this helps.&lt;/p&gt;</description></item><item><title>SQL query: Inserting multiple results into a new table</title><link>http://forums.asp.net/thread/3511866.aspx</link><pubDate>Fri, 13 Nov 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3511866</guid><dc:creator>lorengphd1</dc:creator><description>&lt;p&gt;I have a MS ACCESS 2000 sql query that returns several results, sometimes up to 30 or so.&amp;nbsp; I want to insert these results into a new table all at once, each with their own unique ID [once in the new table].&amp;nbsp; How is this accomplished?&lt;/p&gt;&lt;p&gt;Thanks!&lt;/p&gt;&lt;p&gt;Loren&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Very slw query</title><link>http://forums.asp.net/thread/3491662.aspx</link><pubDate>Tue, 03 Nov 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3491662</guid><dc:creator>atefyousif</dc:creator><description>&lt;p&gt;
These two SP are the same in all , the only difference is the underlined line, in the fisr case it works 20 times faster than when is used is nol null ???
I dun nu&lt;/p&gt;&lt;p&gt;
ALTER Procedure [dbo].[GetNumberOfWOForMachine]
			(
			@TopN INT=10
			)
&lt;/p&gt;&lt;p&gt;			as&lt;/p&gt;&lt;p&gt;
			BEGIN
&lt;/p&gt;&lt;p&gt;ALTER Procedure [dbo].[GetNumberOfWOForMachine] ( @TopN INT=10 )&lt;/p&gt;
&lt;p&gt;as&lt;/p&gt;
&lt;p&gt;BEGIN&lt;/p&gt;
&lt;p&gt;WITH TemporaryTable(	StartTime	 ,FinishTime	 ,WorkOrderCode	,MachineName) AS	(	SELECT	 Min(StartTime) as StartTime ,Min(FinishTime) as FinishTime	,WorkOrderCode , MachineName FROM	 CP_WorkOrderStepsView GROUP BY WorkOrderCode, MachineName ), Temp2(NumberOFOrders,MachineName) AS(	SELECT COUNT(WorkOrderCode) As NumberOFOrders,MachineName FROM TemporaryTable GROUP BY &lt;b&gt;&lt;span class="Apple-style-span" style="text-decoration:underline;"&gt;MachineName HAVING ISNULL(MachineName,&amp;#39; &amp;#39;)&amp;lt;&amp;gt; &amp;#39; &lt;/span&gt;&lt;/b&gt;&amp;#39; )&lt;/p&gt;
&lt;p&gt;SELECT TOP (@TopN)* From Temp2 ORDER BY NumberOFOrders DESC&lt;/p&gt;
&lt;p&gt;END&lt;/p&gt;
&lt;p&gt;Go&lt;/p&gt;&lt;p&gt;
--------------------------------------------------------------
--------------------------------------------------------------
&lt;/p&gt;&lt;p&gt;ALTER Procedure [dbo].[GetNumberOfWOForMachine]
			(
			@TopN INT=10
			)
&lt;/p&gt;&lt;p&gt;			as&lt;/p&gt;&lt;p&gt;
			BEGIN&lt;/p&gt;&lt;p&gt;
			WITH TemporaryTable(	StartTime				,FinishTime						,WorkOrderCode	,MachineName) 
			AS	(	SELECT		Min(StartTime) as StartTime ,Min(FinishTime) as FinishTime	,WorkOrderCode  , MachineName 
					FROM		CP_WorkOrderStepsView 
					
					GROUP BY WorkOrderCode, MachineName 
				),
				Temp2(NumberOFOrders,MachineName) AS(	SELECT  COUNT(WorkOrderCode) As NumberOFOrders,MachineName  
			FROM TemporaryTable 
			GROUP BY &lt;span class="Apple-style-span" style="text-decoration:underline;"&gt;&lt;b&gt;MachineName
			HAVING MachineName IS NOT NULL&lt;/b&gt;&lt;/span&gt;
			)
&lt;/p&gt;&lt;p&gt;			SELECT TOP (@TopN)* From Temp2   ORDER BY NumberOFOrders DESC
			END
			Go
&lt;/p&gt;</description></item><item><title>Question on automating a MySQL query LIMIT statement</title><link>http://forums.asp.net/thread/3451569.aspx</link><pubDate>Sat, 10 Oct 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3451569</guid><dc:creator>Jay-B</dc:creator><description>&lt;p&gt;I asked this somewhere else, but since I&amp;#39;m using ASP.net with MySQL, I&amp;#39;m going to ask this in here, too:&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I
have a large database that has multiple items associated with one
group. What I was doing was searching the table for items with the
group ID, and then doing a LIMIT X ASC statement manually for the number
of items associated with that group. This returned only the latest data
for this group. Example table might look like this:&lt;/p&gt;
&lt;p&gt;Tempature of device&amp;nbsp;&amp;nbsp; 88 degrees 10/10/2009&lt;br /&gt;
Status of device&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; running&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/10/2009&lt;/p&gt;
&lt;p&gt;This device might have 6 things associated with it, but I only
need to know the above 2. So I set each one with a boolean to display
or not to display bit (0 or 1) and added the boolean to my query. (And
doing this does work just the way I want).&lt;/p&gt;
&lt;p&gt;Here is the problem: Using the above example, I can do a
report and set a query LIMIT statement to LIMIT 2...but that involves
me looking at the display bits and saying that group only needs to
display two records and then adding LIMIT 2 ASC to the query.&lt;/p&gt;
&lt;p&gt;I
would like to automate this somehow, but I don&amp;#39;t know how. I need a
query to search a table for the group, see how many display bits are
set for that group, and then set a LIMIT X ASC based on that number. Or maybe there is a much better way to accomplish this???&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;A point in the right direction to do this would be greatly appreciated.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt;
Jay&lt;/p&gt;</description></item><item><title>MySQL Query with a variable on ASP.net </title><link>http://forums.asp.net/thread/3445706.aspx</link><pubDate>Wed, 07 Oct 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3445706</guid><dc:creator>Jay-B</dc:creator><description>&lt;p&gt;Using, VWD 2008 express, I&amp;#39;ve been working through a MS tutorial called &amp;quot;Creating Master/Detail Web Pages in Visual Studio.&amp;quot; The tutorial is simple. A dropdown list, set to autopostback from a table, that when selected, pulls up the data based on the variable category id. &lt;/p&gt;&lt;p&gt;What I have works in mssql, but I have convereted the data to tables in MySQL and I need to do the exact same thing. I can&amp;#39;t get it to work when I use a variable in MySQL. For what I&amp;#39;m working with, I HAVE to use MySQL. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Can someone please show me the syntax to use a variable in a MySQL query statement?&lt;/p&gt;&lt;p&gt;Here is a working mssql statement:&lt;/p&gt;&lt;p&gt;SelectCommand=&amp;quot;SELECT [ProductID], [ProductName], [CategoryID] FROM [Products] WHERE ([CategoryID] = @CategoryID)&amp;quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I know I have to remove the brackets, but the variable format is what I really, really need to know. Whatever I have tried, hasn&amp;#39;t worked at all.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Jay-b&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;pre name="code" class="vb.net"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Join on table with multiple instances on one side</title><link>http://forums.asp.net/thread/3425096.aspx</link><pubDate>Fri, 25 Sep 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3425096</guid><dc:creator>Metalore</dc:creator><description>&lt;p&gt;I&amp;nbsp;have two tables I want to join on customer id&lt;/p&gt;
&lt;p&gt;table a&amp;nbsp;has one instance of a customer&lt;/p&gt;
&lt;p&gt;table&amp;nbsp;b&amp;nbsp;has&amp;nbsp;three instances of&amp;nbsp;the same customer&lt;/p&gt;
&lt;p&gt;When running the query, I am getting 3 results being returned which is not correct. I need just one to be returned. I have tried joining on another select, using distinct, max, top 1 etc etc but can&amp;#39;t get the correct result. Can anyone give me an idea what route I should take to get around this issue?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;</description></item><item><title>What is the best way to make a PDF from SQL Query data?</title><link>http://forums.asp.net/thread/3423733.aspx</link><pubDate>Thu, 24 Sep 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3423733</guid><dc:creator>KenNichols</dc:creator><description>&lt;p&gt;I have a SQL Query that is 8 columns wide and well over 1000 rows long.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Right now I have it displayed on the page in a GridView with paging.&lt;/p&gt;
&lt;p&gt;I need to send the data to a PDF, what is the best way to do this?&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t need the exact GridView Data I will use a separate Query for the PDF.&lt;/p&gt;</description></item><item><title>Help with SQL query to count based on values TWO separate fields</title><link>http://forums.asp.net/thread/3424193.aspx</link><pubDate>Thu, 24 Sep 2009 04:00:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3424193</guid><dc:creator>EricCagle</dc:creator><description>&lt;p&gt;I need to come up with an SQL query that counts the number of occurrances that a number in TWO fields occurs in a table.&amp;nbsp; I&amp;nbsp;have been fighting with it all day and have yet to come up with a working query.&amp;nbsp; I am fairly certain that I need to use a subquery to achieve this, but cannot seem to get it to give the correct results.&lt;/p&gt;
&lt;p&gt;Here is a rough sample of the data layout:&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;id	mydate		type	size1	size2
1	1/16/2009	E	15	
2	2/4/2009	E	15.5	15
3	2/18/2009	N	14	
4	3/6/2009	E	16.5	
5	4/19/2009	E	16	14.5
6	5/15/2009	N	14	
7	5/28/2009	E	15	15.5
&lt;/pre&gt;
&lt;p&gt;What I need to do is count the number of occurrances in the table that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Type =&amp;nbsp;&amp;quot;E&amp;quot;&lt;/li&gt;
&lt;li&gt;(size1&amp;nbsp;&amp;gt;= 15 AND &amp;lt; 16) OR&amp;nbsp;(size2 &amp;gt;= 15 AND &amp;lt; 16)&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;In the sample data above, id 1 would count as 1, id 2 would need to count as 2, id 5 would count as 1, and id 7 would count as 2.&amp;nbsp; Thus for this query, the resulting count would be 6.&amp;nbsp; I have been able to get a query to get &amp;quot;close&amp;quot; but I believe the problem lies with the records that have two fields with a valid value only add one to the count.&lt;/p&gt;
&lt;p&gt;Any help in the right direction would be greatly appreciated.&lt;/p&gt;</description></item></channel></rss>