Canīt Get Select Count(*)... GROUP BY To Work

Iīm trying to build a forum of my own but have stumbled on my first problem as early as the opening page.

To the problem: I want to show a simple forum layout with tables looking something like
this:

Forum Name | Topics | Posts | Last Post
---------------------------------------------------
General | 1 | 4 | Webmaster, 09 Feb -06

To do this I use the following SQL;

sqlPosts = "SELECT Date, COUNT(Date) as NrOfPosts FROM ForumPosts WHERE
ForumID = " & rsForum("ForumID") & " GROUP BY Date ORDER BY Date DESC"

But this doesnīt give me the right numbers. Instead of showing Topics to
be 1 and Posts to be 4 it shows Topics to be 1 and Posts to 1.

But if I use a simpler sql, like this;

sqlPosts = "SELECT COUNT(Date) as NrOfPosts FROM ForumPosts WHERE
ForumID = " & rsForum("ForumID") & " ORDER BY Date DESC"

Then it works, but I canīt get any other info from the table, like date,
userid etc. Code:

View Replies


ADVERTISEMENT

Select Count(*)

I have tried everything possible and still I cant understand why one of the codes work.
This one works, uses a Form to get required info. Code:

View Replies View Related

Select Count(*) ??

I need to set a variable to a select count(*) so I can check if something exists.
For example I have:

SQL = Select field from table where a = adf and b = fdad
set rs = conn.execute(sql)

variablec = rs("c")

But I want to do it with a count so i can use:
If variablecount > 1 Then
newvariable = true

down the line.

View Replies View Related

Select COUNT ?

My problem is using the SELECT COUNT to count the total of call in students. I get the correct count when they is no zero record. But when zero record returns, the count got mix up.. Code:

View Replies View Related

Select Count

How do I count the number of students in a table where their next_Action field is equal to "Follow up". Plus, how do I display out the result?

View Replies View Related

Select Count

Code:

dim sumv, mySQL, conntemp, rstemp
mySQL="SELECT COUNT(*) FROM crminfo where open = '1'"
call getFromDatabase(mySQL, rstemp, "sort2cat.asp")
if not rstemp.EOF then
response.write rstemp.count
end if

View Replies View Related

Random Record With SELECT TOP Does NOT Work

<%
Dim oConn, oRS, randNum
Randomize()
randNum = (CInt(1000 * Rnd) + 1) * -1
Set oConn=Server.CreateObject("ADODB.Connection")
Set oRS=Server.CreateObject("ADODB.recordset")
oConn.Provider="Microsoft.Jet.OLEDB.4.0"
oConn.Open Server.MapPath("temp.mdb")

oRS.Open "SELECT TOP 1 EMAIL_ADDRESS, r = Rnd(" & randNum & ") FROM TABLE1 ORDER BY r", oConn, adOpenStatic, adLockReadOnly

Response.Write oRS("EMAIL_ADDRESS")

oRS.close
oConn.close
Set oConn = nothing
Set oRS = nothing
%>

this gives the error: "No value given for one or more required parameters".

what i would really LOVE is for someone to fill in whatever required parameter im missing, but more important i would like to understand whats going on. there are people who go through life dumb and happy once something "works", but i need to understand how and why its working. even if this code did work, im confused with the SELECT statement (no, i dont have much SQL experience aside from basic queries). what is the "r = Rnd" line doing in the middle of the querie? how am i ordering by r?? also, i dont have an indexed, primary "ID" field in this databae. is that ok for this code to work?

View Replies View Related

Select Count(*) Always Returns Zero

using mysql - vbscript and oledb provider

I have a table with 2 records

I do this in asp

rs.open "select count(*) as countervar from sqltable" ,oconn,1,1

response.write rs(0).value or response.write rs(0) gives zero and not 2 as to be expected

Also I would also like to be able to do calculations like this

rs.open "select 10 * 2 as result" ,oconn,1,1

response.write rs(0) also gives zero and not 20 as expected

can't this be done?

View Replies View Related

Select File Count

i have a bit of a weird question . I'm looking for a pull statement that pulls the number of files in a specific folder , But at the same time it wouldn't pull the number of pictures in this folder either . I have no idea how to write this code and I'm wondering if anyone could help me out?

View Replies View Related

Select Count Statement

After i have SLECT COUNT(X) as "A" from....

I want to issue a condition to check for the number of records. this is what i do

Code:

SQL = "select count(*) as "A" from..."
set objRec = objConn.execute(SQL)

if objRec("A") = "3" then

is this statement correct? Doesn't seems working.

View Replies View Related

Group By? Distinct?

When I just - SELECT DISTINCT atblProducts.ID AS ProductID, it selects distinct Product IDs but when I add other columns to the select, it doesn't select the ProductID as DISTINCT.

I've heard to try "GROUP BY..." Code:

View Replies View Related

IIS Group Access

I have a asp app that I wish to limit execution access to a universal
security group during beta test...
I've tried restricting permissions using ntfs, the virtual directory
and the net.config file (which I assume will not work as this is not a
vb.net app).

View Replies View Related

Group Array

I have several arrays, created by splitting a string of comma delimited values, as follows:

arrOne = split("1,2,2,2,3,6,3,7",",")
arrTwo = split("5,2,1,6,5,5",",")

What I want to be able to do is to group the arrays so that I know how much of each there are. I need to output results in the following format:

Number / HowManyTimesThatNumberOccursInTheArray.

So for example, the above would output:

ArrOne:
1 / 1
2 / 3
3 / 2
6 / 1
7 / 1

ArrTwo:
1 / 1
2 / 1
5 / 3
6 / 1

These can literally just be output as a string if needs be. Is this possible? If so, how do I go about achieving it?

View Replies View Related

Group My Catalogue

I have a catalogue table and forum table in my database. In the cata table , it has ASP, PHP, JSP 3 record. In the Forum Table, it has ASP intro, ASP Install, PHP intro, PHP install 4 record. I want to group the ASP intro, ASP install in the ASP group and The same with the PHP group.
How can i do ? ( By ASP ) .
( Could you please give the asp source code to get the data from database by group ? When the Cat_ID at the 2 table is equal, they are in the same group)

View Replies View Related

Administrators Group Name

I try to read out the Administrators Group name from a specific Computer in our Network with the aid of the RID.

View Replies View Related

SQl, Group By - Error

I'm trying to execute this sql below:

strsql="select Name,CName from Task where Name like '%" & request.QueryString("PrintName") & "%' and CName Like '%" & request.QueryString("PrintName") & "%' group by name"

but it doesn't work and i get this error:

You tried to execute a query that does not include the specified expression 'CName' as part of an aggregate function.

View Replies View Related

Group By Average...

I want to Group my records by the average of a field...

I tried using 'GROUP BY AVG(Rating)' but that's an illegal use...

Is there another way, besides opening another recordset? I also used:

... AVG(Rating) as AverageRating GROUP BY AverageRating ...
But, same problem...

View Replies View Related

Group Permissions

I have a asp page that I need to check to see if the current logged on user is a member of a specific active directory group. How can I do this? I have tried so many different LDAP code examples and none seem to work.

Do I need to include a administrator username and password in the code? Does any have any samples of code I can try?

View Replies View Related

Query SQL GROUP BY

I have this problem with table of database MySQL. My table with fields ID, Number and Description: Code:

ID ====== NUMBER ======= DESCRIPTION
1 ====== 9168381650==== CDR VER-CS AP-UPS SANLUCA
2 ====== 9168381659==== CDR VER-CS AP-UPS SANLUCA-9
3 ====== 9168381651==== CDR VER-CS AP-UPS SANLUCA-SQ S.SANLUCA
4 ====== 9168381652==== CDR VER-CS AP-UPS SANLUCA-SQ DIST.GUSPIN
From this table I need to have the total of records data all under the description CDR VER AP-CS-UPS SANLUCA.

Is a hierarchy structure where IDs 2, 3 and 4 belong to the description ID 1. I don't like to see the data individually for each description, but the grouping data for macro-DESCRIPTION. For example:

The total records in table are 4, the query return:
"There are 4 records total for description CDR VER AP-CS-UPS SANLUCA."

View Replies View Related

Group Members

I have a asp page that I need to check to see if the current logged on user is a member of a specific active directory group. How can I do this?

I have tried so many different LDAP code examples and none seem to work. Do I need to include a administrator username and password in the code? Does any have any samples of code I can try?

View Replies View Related

Group By Order By

I have the following statement that is working just fine:

SQL = "select* from products GROUP BY name ORDER BY price"

I have many products with the same name but with different prices and I want to display unique records along with other information but I want to display the cheapest product first. It is displaying the first record in the table with that name but not the cheapest distinct record in the list of all distinct product names. Code:

View Replies View Related

Grouping And Totals For Group

I am writing a report using ASP and am having trouble displaying the data in the way i want. I'm collecting turnovers for various companies and each of the companies has a county code. e.g. Yorkshire is defined as number 2.

I need to group the companies together by county and need to display a totals line for those members only and then on the following lines I want the next county and its companies.

I can group the counties together but the totals line I'm displaying appears after each companies rather than after the group of companies for a given county.

I use a do while loop to check that there is data in the database for each company. I tried putting the totals line outside the loop and that only shows 1 totals line for ALL companies.

View Replies View Related

Counting By Group And Selection

I am trying to show some stats. However I have four levels to choose from, which are shown as true/false. I want to count each entry by employee and categorize it only under the highest level achieved. One entry can have multiply Levels. Hope this make sense my mind is a little foggy today.

Here is the sql statement I am using. I have added the levels as or however I want to count each level but only the highest level achived. I don't know if it would be easier to do this in a SQL statement or in vb script. Code:

View Replies View Related

Invalid Use Of Group Function ??

The query works fine without ordering. But when I try to put ORDER BY that error message appears.

My query is working when it looks like that:

"Select TAB1.WCUST, TAB2.name, sum(TAB1.qty) AS SUMQty, sum(TAB1.wamt) AS SUMWamt from TAB1 LEFT JOIN TAB2 ON TAB1.WCUST=TAB2.name Where TAB1.WMNID=10 GROUP BY TAB1.WCUST, TAB2.name;"

But after I add ORDER:

"Select TAB1.WCUST, TAB2.name, sum(TAB1.qty) AS SUMQty, sum(TAB1.wamt) AS SUMWamt from TAB1 LEFT JOIN TAB2 ON TAB1.WCUST=TAB2.name Where TAB1.WMNID=10 GROUP BY TAB1.WCUST, TAB2.name ORDER BY sum(TAB1.wamt) DESC;" it gives me the error message:Invalid use of group function.

I tried to order the query by WAMT and it was OK.

View Replies View Related

Checking A Users Group

How can I check a users group in ASP? I can pull their logon and domain with Server Variables, but how can I get their group?

View Replies View Related

Multiple Group Rows

How do you group multiple rows from a sql recordset on a unique id in ASP? (ie: I get 5 rows for id=9, but just want to display the top row based on my Order By).

View Replies View Related

Creating User Group

i need to creat a user group, where as members can log in and discuss issues, like here (asp forum). I need to do it from A to Z,i found this link :http://www.siteexperts.com/tips/com.../ts02/page2.asp, but i didn t find my way yet

View Replies View Related

Group By Statment Problem

i want to display the number of people logged on at each location... when someone logges in they get a type=1... that works great but when i try to group by the NasName thats the location name.. Code:

View Replies View Related

Check Dropdown Group

I have done ASP for a while but never found a quick way to handle this issue.I have 8 dropdown boxes. Is there an easy to check that only 1 has selected 'Yes' and the others are 'No' without checking infinite combinations?I usually do this with alot of coding for the combinations.

View Replies View Related

How To Check A Users NT Group

I have an intranet site, and I need to control certain pages with NT Group permissions. I need to check that when a page is loaded, if the user is a member of the right NT Group, then the page displays, else an access denied page displays.

I am having trouble with the bit of code that gets and checks the users NT Group. I can get and check their Domain and Username, just not the Group.?

View Replies View Related

Check Member Of NT Group

i can use Request.ServerVariables to check the login user. is it possible to check whether the login user is the member of the NT security group? it is because i wish to create a dynamic banner according to respective NT security group.

View Replies View Related

Radio Button Group

I have a simple html page with a radio button group on
it. I am submitting that page into an asp page. How do I
know what button the user has checked?

View Replies View Related

AD Group Membership Check?

I'm rather new to ASP and am having trouble with implementing a group membership check in one of my functions. I have this function which I use for authentication pass-through:
Code:

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved