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


ADVERTISEMENT

Using Distinct

I have a Drop Down box that is being populated using the SQL Distinct
command. How do I get it so it doesn't show Null values?

Here is my SQL statement

sSQL = "SELECT DISTINCT Title FROM Everyone ORDER BY Title ASC"

View Replies View Related

Distinct

this is my query

SELECT distinct(prof.id_num),prof.name,education.educ_lev el,education.school,education.degree,agency_info.c ampus
FROM prof inner join education on prof.id_num=education.id_num inner join agency_info on education.id_num=agency_info.id_num where education.educ_level<>'course' and agency_info.campus='colle'
ORDER BY education.school
course="tertiary"

still it shows duplicate records. it displays secondary,primary record of the employee

View Replies View Related

Distinct And Top In Select

I want to use a distinct and a top in a select statement, however I
want the distinct to only apply to one of the columns. For example

SELECT DISTINCT TOP 15 col1,col2,col3,col4 from table1

I only want the distinct to apply to say col2. Is there a way to do
this?

View Replies View Related

A 'distinct' Problem

I am trying to draw out from the database a distinct artists in relation to a variable which is 'cat'.

strsql = "SELECT distinct art_Artist, cat_ID, art_Category, art_Title, art_BDescription, art_Price, art_PicFull " &_
"FROM eventDisplay WHERE art_Artist='" & cat & "' "&_
"ORDER BY art_Artist"

Whats happening is that at this moment cat = Lee Jones, and he is in the databse three times with exactly the same info except for one subject which doesnt matter in this case, therefore we only need to see his name once being pulled.

Im sure this code has worked before but it doesnt seem to be workign here, i thought maybe its because his name is entered into the database with a gap inbetween his first name and last, but im probably wrong...

View Replies View Related

Distinct Filter

I have information in a database with the following structure:
3 Divisions - each division has several districts. Each district has several regions and each region has several areas.
I have a recordset of every area with the region, district and division they belong to.
I have 4 drop down menus on my page - area region, district and division.
How can I filter my recordset before each dropdown, so it only has DISTINCT records

View Replies View Related

SQL Distinct Problem

Here is the code that just won't work

Set rsPlayers = cnnDB.Execute("SELECT DISTINCT Players.PlrEmail FROM Players INNER JOIN Sessions ON Players.PlrID = Sessions.SsnPlrID WHERE Sessions.SsnGmID = 14 AND Players.PlrEMail <> 'Unknown' ")

If I use SELECT * From Players I get duplicates. I only want unique emails for the query.

View Replies View Related

Distinct An Inner Statement

How can I make this inner statement distinct? I've got the coding as follows but it displays every record anyway. Any way around this?Code:

sql = "SELECT DISTINCT cheats.*, searchtable.title FROM cheats, searchtable WHERE cheats.pin=searchtable.pin"
Set rschancheats = Server.CreateObject("ADODB.Recordset")
rschancheats.Open sql, conn, 3, 3

View Replies View Related

Select Distinct

i have a DB with table named Products. pCategory lists several names of teams of varing leagues (NBA, NFL, MLB, etc...) I want a table to display only the NBA teams. I have a field named pGroup which has NBA, MLB, etc... for each team. How can I display all fields where pGroup="NBA." I thought the code would work below, but it didn't.

<%sql_getProducts = "SELECT DISTINCT pCategory WHERE pGroup="NBA" FROM products"

View Replies View Related

Distinct Field

I am building a real estate listingwhere the vistor choses a city or cities and the results display the counties they are in. The problem I have encountered is that
I am trying to make search results from a query that displays the county only once even if the visitor has chosen many cities within the same county.

I problem is that when the county field is set to be distinct, the recordset pulls out only the first record of that group. Therefore, when a search is performed on that query it will not find a potenial county even if the city belongs to that county.

View Replies View Related

ORDER BY DISTINCT

I'm trying to get this SQL statement to work:

SQL = "SELECT distinct(catagory) FROM PicAlbum ORDER BY dateadded"

I keep getting this error:

ORDER BY clause (dateadded) conflicts with DISTINCT

Is it possible to do a ORDER BY using a distinct?

View Replies View Related

Distinct Dates

I have a table containing newsletter articles. Each article has a zone which is either a section, division, district or all, and a edition they belong to.

I have the following sql statement in my vbscript to give a list of newsletter edition dates if there are articles relating to the relevant section, division or district:

"SELECT DISTINCT (edition) AS editions, zone FROM t_newsletter WHERE ((zone='"+sec+"') OR (zone='"+dis+"') OR (zone='"+div+"'))"

the trouble is that if there is an article in november for the relevent section and also an article for the relevant district then that date appears twice - how can I stop this, or do I need to go into my database?

View Replies View Related

Distinct Statement

How can do double select or do I have to loop though? I would like to go an strSQL = * From main but I only want to have one person from each team in week x, team being a field. I could select distinct teams then loop and simply only Do while once per team however I'd like to put it all together but of course

Select Distinct TEAM Where Week = vweek

can not be done. Any ideas. I saw some thing about being able to have a second statement underneath in [] once but was I dreaming?

View Replies View Related

Distinct In Sql Not Working!

I have my piece of code like that...everything is working nice but when i retrieve values from the database, the DISTINCT part does not seem to work... Code:

View Replies View Related

Selecting Count(distinct Value)

I want to select just one field to display using sql and I want to have another variable that counts how many fields of the same value there are. My code looks something like this but i'm getting an error...

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal. Code:

View Replies View Related

Select Distinct Values

Some values in my array are repeating. Is there a way to select distinct values from the script like you can in sql?

View Replies View Related

Display Distinct Records

i am inner joing two tables customer and program. if i use select distinct i still get duplicate records displayed. how can i display distinct records for a customer by cust_no but still pull fields from program.

my customer and program table are joined by the cust_no field but in the program table the customer may have 10 different programs.

I tried "Select DISTINCT customer.cust_no ,customer.lastname, customer.firstname, program.season inner join program on customer.cust_no = program.cust_no"

View Replies View Related

Selecting Distinct Intervals

I need help programming a search function. I want to narrow down a search function regarding time. I figure the best way to do this is to select a higher interval and a lower interval, and then have an sql function that grabs the times from within that range.Code:

sql = "SELECT DISTINCT place, time FROM bussystem WHERE time >= '"&timey&"'"
Set rscurrent = Server.CreateObject("ADODB.Recordset")
rscurrent.Open sql, conn, 3, 3

sql = "SELECT DISTINCT place, time FROM bussystem WHERE time <= '"&timey&"'"
Set rsrecent = Server.CreateObject("ADODB.Recordset")
rsrecent.Open sql, conn, 3, 3

View Replies View Related

SQL SELECT DISTINCT Problem

I have: Code:

sql = "SELECT DISTINCT LName FROM myTable ORDER BY userID"

But this produces an error saying you cannot use DISTINCT and ORDER BY in the same statement. What is the best way I can achieve a sorted list of unique values?

View Replies View Related

SELECT DISTINCT From Two Tables

I have two table which are related:

table1 holds personellinformation
table2 holds nodeInformation

The nodes in table2 can have a nodeOwner which will then get a recordID from
table1. A person can own multiple nodes.

Now I want to display all nodeowners, but not the duplicates (if they own
multiple nodes).

What would be the SQL syntax for that, using ASP with VB?

I've tried using DISTINCT, but I do also need the NodeID which is always
unique so I still get all duplicates.

View Replies View Related

Distinct Column Selection

I have used the follwing query before in SQL and its worked fine but not on an access database is the syntax different?Code:

strSQL = "SELECT Count(DISTINCT BID) as varAmount FROM Bookings Where BookedBy = '" & rsStaff("Name") & "'"

The Error i recieve is:

Microsoft JET Database Engine error '80040e14'
Syntax error (missing operator) in query expression 'Count(DISTINCT BID)'.

View Replies View Related

Distinct Phone Numbers With SQL

I will attach a zipped file with data in it. I want to pull distinct phone numbers from column B and column D (as some of the numbers will be the same). then rank by asc order based on TotalCashPrice. If they are the same, I want to compare the TotalCashPrice to TotalCashPrice2. Is that possible?

View Replies View Related

SQL Count Distinct In ACCESS DB

I tried to count distinct colum such as department using following sql:

select COUNT (distinct Department) from table university1;

it cannot recognized distinct and failed. I count to count unique department number, I knew the sql worl for Oracle but not Access DB. Any idea to fix that?

View Replies View Related

Select Distinct Variable

I m trying to use select statement in order to select a distinct word like 'c', but in the database i only want to select c when it occurs on its own not when it appears in another word.

eg i need to select the alphabet 'c' in 'the cat category is c' but not the 'c' in 'cat' or 'category'. I have used the code below but this seem to count all 'c'


select set rsTypes2 = con.execute("SELECT COUNT(two) AS total FROM march where two like '%c%'")

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







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