Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 31st, 2005, 12:13 PM
Registered User
 
Join Date: Mar 2005
Location: Trevose, PA, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Distinct SELECT DISTINCT question...

Okay... Here is my conundrum. I have a table of products. This table is a list of products with associated components listed under one specific system number:

Sysno | Item Number | Description | Rate
----------------------------------------
  1 | C123C | Laptop | 250
  1 | A987A | Lap. Memory |
  1 | A876A | Lap. Case |
  2 | C234C | Projector | 300
  2 | A765A | Proj. Case |
  2 | A654A | Proj. Bulb |
  3 | C345C | Technician | 50
  3 | A543A | Travel |

I realize that this is NOT an ideal product list, but I cannot modify it as it is the company's master database for a completely different complex piece of software.

I want to select all the data from each row (like SELECT *) BUT I only want the first of the distinct Sysno fields so my recordset would look like this:

Sysno | Item Number | Description | Rate
----------------------------------------
  1 | C123C | Laptop | 250
  2 | C234C | Projector | 300
  3 | C345C | Technician | 50

How can I accomplish this through a heavily modified Select statement?

Thank you all SO much in advance!

Reply With Quote
  #2 (permalink)  
Old March 31st, 2005, 03:16 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this..not sure what databae are you using

SQL Server T-SQL Query

SELECT Sysno,Item_Number,[Description],Rate
From Table
Group By Sysno,Item_Number,[Description],Rate
Having Rate IS NOT NULL
Reply With Quote
  #3 (permalink)  
Old April 1st, 2005, 11:20 AM
Registered User
 
Join Date: Mar 2005
Location: Trevose, PA, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmmm, I guess I didn't specify too much.

My bad...

I am programming in VBscript, pulling data through ODBC from a FoxPro Database.

Also, I would really like to have the SQL statement select the distinct products via the Sysno. This way, I dont take a chance on their being additional rate data that would throw the statement off. I know for sure that the Sysno data will not change.

Reply With Quote
  #4 (permalink)  
Old April 6th, 2005, 10:23 AM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try using SELECT DISTINCT Sysno, Item Number, Description, Rate FROM TableName.

Reply With Quote
  #5 (permalink)  
Old August 18th, 2005, 08:53 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default


EndEffect,

Given that you are using ODBC with a Foxpro database, you could do the following:

SELECT * FROM MyTable GROUP BY Sysno

Note that this is not normally legal SQL syntax, but it works with the Foxpro ODBC driver because the driver is up to date only as of Visual FoxPro 6.0, and that version was very forgiving of this syntax. It should produce the result you want.

Mike


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Distinct Question DeMoNN SQL Server 2000 4 November 1st, 2006 02:52 PM
Select Distinct Question DeMoNN Access 4 November 1st, 2006 11:15 AM
Select Distinct Question acdsky SQL Server 2000 6 October 31st, 2006 05:16 PM
Select Distinct kirkmc Access 13 July 13th, 2006 01:26 PM
select distinct bmains ADO.NET 0 April 8th, 2004 02:50 PM



All times are GMT -4. The time now is 03:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.