Query to create higher or equal matched values

jaryszek

Registered User.
Local time
Today, 13:58
Joined
Aug 25, 2016
Messages
756
Hi Guys,

i have table like here:

attachment.php


So KeyName and DiskSize corresponding.

And what i want is to get this table:
attachment.php

So for keyName P6-64-Premium_SSD i have 3 keyNames which DiskSizes are bigger or equal: P6-64-Premium_SSD, P20-512-Premium_SSD, P30-1024-Premium_SSD.

For P20-512-Premium_SSD we have P20-512-Premium_SSD (equal) and higher value is P30-1024-Premium_SSD.

For P30-1024-Premium_SSD we have only equal value P30-1024-Premium_SSD.

Database sample in attachment,

How can i write query to achive this?
Please help,
Jacek
 

Attachments

  • Screenshot_39.png
    Screenshot_39.png
    30.7 KB · Views: 150
  • Screenshot_40.png
    Screenshot_40.png
    87.8 KB · Views: 157
  • Database19.accdb
    Database19.accdb
    420 KB · Views: 83
Hi. I’m already in bed but try looking into non-equi join queries. See you in the morning.
 
ok thank you,

i tried with:

Code:
SELECT TableSource.KeyName, TableSource_1.KeyName
FROM TableSource, TableSource AS TableSource_1
WHERE (([TableSource_1].[DiskSize]>[TableSource].[DiskSize]));

but it failed.

attachment.php


Jacek
 

Attachments

  • Screenshot_41.png
    Screenshot_41.png
    49.9 KB · Views: 127
  • Database19.accdb
    Database19.accdb
    420 KB · Views: 90
Try this
Code:
SELECT TableSource.KeyName, TableSource_1.KeyName AS HigherKeySizes
FROM TableSource, TableSource AS TableSource_1
WHERE (((TableSource.DiskSize)>=[TableSource_1].[disksize]))
ORDER BY TableSource.KeyName DESC;
 
o wow thank you very much!

Working like a charm!
Jacek
 
You're welcome.
Here's another method but it can only be used in SQL view due to the non-equal join

Code:
SELECT TableSource.KeyName, TableSource_1.KeyName AS HigherKeySizes
FROM TableSource AS TableSource_1 INNER JOIN TableSource ON TableSource_1.DiskSize >= TableSource.DiskSize
ORDER BY TableSource.KeyName DESC;

BTW did you try out the approach I outlined recently about deleting specific duplicates?
 
hi Colin,

thanks !

Sorry my tasks changed and i didnt have time for it yet :( I will investigate.

Best,
Jacek
 

Users who are viewing this thread

Back
Top Bottom