"DISTINCT" Command

I use the following SQL command in my ASP webpage.

SELECT DISTINCT CarList,CarListID FROM Model

My problem is that I would like for "CarList" to be distinct and not "CarListID". How can I fix this problem?

View Replies


ADVERTISEMENT

Error - 2147217908 Command Text Was Not Set For The Command Object

I am getting the above error when trying to execute the following code:

View Replies View Related

Command Text Not Set Command Object

I have an online application. I get the following error when a user selects an option from one drop down list but doesn't select an option from another drop down list. Here is the error:

Microsoft OLE DB Provider for SQL Server error '80040e0c' Command Text was not set for the command object. Code:

View Replies View Related

Command Text Was Not Set For The Command Object

I have an online application. I get the following error when a user selects an option from one drop down list but doesn't select an option from another drop down list. Here is the error:

Microsoft OLE DB Provider for SQL Server error '80040e0c'
Command Text was not set for the command object.

Line 87
Line 87 = rs1 = conn.execute(finalSQL)

Here is the page causing the error. Code:

View Replies View Related

Command Text Was Not Set For Command Object

I keep getting this error. I searched the forums, and found one. It said to basically replace elseif with else. It worked for that person.

I tried it and it didn't work. So what i decided to do was, remove all of the if statements and keep one. Even with just one if statement i get the same problem. Does anybody know what is wrong? It worked fine, up until i added the if statement. I need them there though for a reason.

Personally i think, it;s not getting the value from the request form, and hense it isn't picking anything up. What do you lot reckon? Code:

View Replies View Related

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

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

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

Count Records With Distinct Values

I have got an access database with 100's of records in it(each record is just one word/phrase)...i am looking to develop some asp code that will select all distinct values in that table and list the number of times that text appears.

For example in the table contains the following records: -

banana
apple
orange
apple
apple
orange
apple

I want the following output: -

apple - 4
orange - 2
banana -1

View Replies View Related

Sql_getVAR = "SELECT DISTINCT

please bare with me here:
<%
dim VAR(2)
VAR(1)="nba"
VAR(2)="mlb"

sql_getVAR = "SELECT DISTINCT pcity FROM VAR"
Set getVAR = Conn.Execute(sql_getVAR) %>

I want several table according to the sport (nba,mlb, nfl etc...) I thought if i put the above code on an asp page (page02.asp) and then specified VAR on page01.asp with the link for NBA being /teams_02.asp?VAR=1 it would display the fields from the "nba" table.
Of course it did not saying the error was that VAR was not defined. Can someone tell me what I am doin wrong or if you understand it, explain a better way to me.

View Replies View Related

Number Of Fields Per Distinct Field

I have a table [table] with two fields [type] and [ID]. I am trying to create a table with the number of IDs per distinct type. So, the return table would be {distinct [type]}, {count per {distinct [type]}. I am stumped; I believe this must be two queries?

View Replies View Related

Function To Select 3 Random Numbers Which Are Distinct

I need to generate three random numbers between 1 and 100, but they need to be different.

e.g. 3,43,88 would be fine but 5,76,76 would not.

The function I have to generate a single random number is:

function funRandomNumber(intHighestNumber)
randomize
funRandomNumber = int(rnd * intHighestNumber) + 1
end function

called by: funRandomNumber(100)
Can anyone see how this can be modified to do what I need?

View Replies View Related







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