Ask a Question related to ASP Database, Design and Development.
-
Gary #1
ASP, using SQL COUNT as a condition in IF ELSE statement
I am trying to do a simple "less than" conditional statement, and hitting a
brick wall if I use a database element with it.
This DOES work:
<%
if Request.QueryString("PC") < 10 then Response.Write("less than ten") else
Response.Write("more than or equal to ten") End if
%>
This DOES NOT work:
<%
if Request.QueryString("PC") < Record.Fields.Item("count(*)").Value then
Response.Write("less than COUNT") else Response.Write("less than or equal to
count") End if
%>
The only difference is that in the first example a number is used as the
condition. in the second example, I have counted the number of rows in a
table, and I want to use that number as the condition. The SQL select is:
SELECT count(*), EnquiryDate
FROM lfmasterleads.partner_enquiries
WHERE EnquiryDate = CURRENT_DATE() GROUP BY EnquiryDate
Any help greatly appreciated!
Darren.
Gary Guest
-
condition
hey jan... i do it like this: function existRec (name) { for (i=0; i<recs.length; i++) { if (recs == name) { return true; } } return false;... -
?: condition
eh, probably dumm question but why is asking to return a value not working here? for (var i=0;i< x.length; i++) { x ? : return true : null; } -
complex condition
I know there must be a way to do the following: if (($foobar > 3) || ($foo="t" && $bar = "b")) {print "yup"} Of course this is wrong, but what... -
DB2 upgrade condition
Hi all, i've got db2 udb enterprise server v. 7.1 .... it's possible to upgrade to 7.2 or 8.1 ? It's free? Thanks Stefano -
Trying to create a condition statement in
Ampersand. && My mistake was that I did not put the word 'javascript:' in front of the script. mybutton.attributes.add ( "javascript:if... -
Aaron Bertrand - MVP #2
Re: ASP, using SQL COUNT as a condition in IF ELSE statement
There is no such column as COUNT(*). See [url]http://www.aspfaq.com/2159[/url]
--
Aaron Bertrand
SQL Server MVP
[url]http://www.aspfaq.com/[/url]
"Gary" <sorry@nocando.com> wrote in message
news:6ibYb.564$Ih4.6389862@news-text.cableinet.net...a> I am trying to do a simple "less than" conditional statement, and hittingelse> brick wall if I use a database element with it.
>
> This DOES work:
> <%
> if Request.QueryString("PC") < 10 then Response.Write("less than ten")to> Response.Write("more than or equal to ten") End if
> %>
>
>
> This DOES NOT work:
> <%
> if Request.QueryString("PC") < Record.Fields.Item("count(*)").Value then
> Response.Write("less than COUNT") else Response.Write("less than or equal> count") End if
> %>
>
> The only difference is that in the first example a number is used as the
> condition. in the second example, I have counted the number of rows in a
> table, and I want to use that number as the condition. The SQL select is:
> SELECT count(*), EnquiryDate
> FROM lfmasterleads.partner_enquiries
> WHERE EnquiryDate = CURRENT_DATE() GROUP BY EnquiryDate
>
> Any help greatly appreciated!
>
> Darren.
>
>
Aaron Bertrand - MVP Guest
-
Gary #3
Re: ASP, using SQL COUNT as a condition in IF ELSE statement
"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
news:enbI4tN9DHA.1472@TK2MSFTNGP11.phx.gbl...> There is no such column as COUNT(*). See [url]http://www.aspfaq.com/2159[/url]
Seems to work for me?
Gary
Gary Guest
-
Aaron Bertrand - MVP #4
Re: ASP, using SQL COUNT as a condition in IF ELSE statement
> Seems to work for me?
Maybe I should rephrase. COUNT(*) is not a column, it is an aggregate. You
cannot refer directly to an aggregate, as the article (and your own "DOES
NOT work" experience) has shown you. You need to define an alias or use the
ordinal number.
--
Aaron Bertrand
SQL Server MVP
[url]http://www.aspfaq.com/[/url]
Aaron Bertrand - MVP Guest
-
Bullschmidt #5
Re: ASP, using SQL COUNT as a condition in IF ELSE statement
<<
I am trying to do a simple "less than" conditional statement, and
hitting a
brick wall if I use a database element with it.
This DOES work:
<%
if Request.QueryString("PC") < 10 then Response.Write("less than ten")
else
Response.Write("more than or equal to ten") End if
%>
This DOES NOT work:
<%
if Request.QueryString("PC") < Record.Fields.Item("count(*)").Value then
Response.Write("less than COUNT") else Response.Write("less than or
equal to
count") End if
%>
The only difference is that in the first example a number is used as the
condition. in the second example, I have counted the number of rows in a
table, and I want to use that number as the condition. The SQL select
is:
SELECT count(*), EnquiryDate
FROM lfmasterleads.partner_enquiries
WHERE EnquiryDate = CURRENT_DATE() GROUP BY EnquiryDate
Any help greatly appreciated!
Darren.Perhaps change:>>
SELECT count(*), EnquiryDate
To be this instead:
SELECT count(*) AS RecCount, EnquiryDate
And then on the first record use the value of objRS("RecCount").
Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
[url]http://www.Bullschmidt.com[/url]
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Bullschmidt Guest



Reply With Quote

