473,471 Members | 4,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

openrecordset select distinct

4 New Member
I am having trouble with getting distinct software to filter with openrecordset select distinct.

Here is my openrecordset and select statement.

Expand|Select|Wrap|Line Numbers
  1. Set rst = dbs.OpenRecordset("SELECT DISTINCT Software.[Software Name], Software.Version, Software.[Operating System], " & _
  2.             "Software.Status, Software.[Status Date], Software.[Approved Platforms], " & _
  3.             "Software.[Code Type], CUsage.[Cost Center], CUsage.[Entered On] " & _
  4.             "FROM Software INNER JOIN CUsage " & _
  5.             "ON Software.[Software Name] = CUsage.[Software Name] " & _
  6.             "AND Software.Version = CUsage.Version " & _
  7.             "AND Software.[Operating System] = CUsage.[Operating System] " & _
  8.             "WHERE Software.[Software Name] = '" & strSoftwareNameOI & "' " & _
  9.             "AND Software.Version = '" & strVersionOI & "' " & _
  10.             "AND Software.[Operating System] = '" & strOSOI & "'" & _
  11.  "ORDER BY Status DESC ", dbOpenDynaset, dbReadOnly)
  12.  
  13.  

My output is showing like this.....

Expand|Select|Wrap|Line Numbers
  1. Software Name    Version    Operating System    Status    Status Date    Approved Platforms    Code Type    Cost Center    Entered On
  2. 2000Times    1.0    Windows    Pending    1/6/2010            2011    2/17/2010
  3. 2000Times    1.0    Windows    Pending    1/6/2010            2012    2/17/2010
  4. 2000Times    1.0    Windows    Active    1/20/2010        Non-controlled Access    2011    2/17/2010
  5. 2000Times    1.0    Windows    Active    1/20/2010        Non-controlled Access    2012    2/17/2010
  6.  

But it needs to look like this...

Expand|Select|Wrap|Line Numbers
  1. Software Name    Version    Operating System    Status    Status Date    Approved Platforms    Code Type    Cost Center    Entered On
  2. 2000Times    1.0    Windows      Pending    1/6/2010            2011    2/17/2010
  3.                                  Pending    1/6/2010            2012    2/17/2010
  4.                                  Active    1/20/2010        Non-controlled Access    2011    2/17/2010
  5.                                  Active    1/20/2010        Non-controlled Access    2012    2/17/2010
  6.  



If anyone could help I would greatly appreciate it. Thanks
Jul 30 '10 #1
1 3793
patjones
931 Recognized Expert Contributor
The DISTINCT keyword works only on entire records. In your example, all four of the records are different. For instance, the Status Date is 2011 in the first record and 2012 in the second record. That difference makes these two records non-distinct, and so DISTINCT will have no effect.

If this is for a report, one way for you to get your desired result might be to open the report in Design view, and use the Group & Sort window to group by the Software Name, Version, and Operating System columns - which would allow you to put those columns in a group header and leave the other columns below the header.

I don't believe there is an obvious SQL solution for this situation.

Pat
Jul 30 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ralph Freshour | last post by:
I have a question about the following PHP script - I got it off a web site tutorial on how to count users logged into your site - my question is the $PHP_SELF variable - it writes the name of the...
5
by: Martin Feuersteiner | last post by:
Dear Group I'm having trouble with the clause below. I would like to select only records with a distinct TransactionDate but somehow it still lists duplicates. I need to select the...
2
by: mfyahya | last post by:
I have two tables, both containing an 'authors' column. Is there a way to get a unique list of authors from the two tables? I tried SELECT DISTINCT `authors` from `table1`, `table2`; but I got an...
3
by: shumaker | last post by:
I was curious... Is there a way to select distinct on a combination of some fields and the for each record returned also get the other fields of an arbitrarily chosen record matching the fields...
9
by: Kelvin | last post by:
Okay so this is baking my noodle. I want to select all the attritbutes/fields from a table but then to excluded any row in which a single attributes data has been duplicated. I.E. Here's my...
6
by: John M | last post by:
Hi, The line below is used to feed a combobox. (It is from a database which is used to log pupil behaviour!) The 'incidents' table contains a list of students who have been involved in incidents....
18
by: mathilda | last post by:
My boss has been adamant that SELECT DISTINCT is a faster query than SELECT all other factors being equal. I disagree. We are linking an Access front end to a SQL Server back end and normally are...
2
by: Jim H | last post by:
I am storing incoming data in memory using a DataTable. After I'm done retrieving the data I need to get the distinct rows. I tried using DataTable.Select but that doesn't work. If I have...
3
by: orekinbck | last post by:
Hi There Our test database has duplicate data: COMPANYID COMPANYNAME 1 Grupple Group 2 Grupple Group 5 Grupple Group 3 Yada Inc 4 Yada...
6
by: Bob Stearns | last post by:
I am getting duplicate rows back from a select distinct statement of the form: SELECT DISTINCT 'jhough', '000111', t0.bhid FROM (SELECT lots of good stuff) t0 LEFT OUTER JOIN another_table ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.