Jan 25 2022 09:41 AM
Could someone help me construct query to find location that only has HP in below table;
vendor location
HP TX
Cisco TX
Dell TX
HP CA
HP WA
Dell WA
HP OR
Cisco OR
HP WI
Dell WI
Cisco WI
Jan 26 2022 04:34 AM
Hi @Alex_Kim245 --
Try something like the query below. Take care.
SELECT
Vendor
,VendorLocation
FROM
Vendor
WHERE
Vendor = 'HP'
Jan 26 2022 05:58 AM
Jan 26 2022 08:31 AM
Hi @Alex_Kim245 --
Apologies, I misunderstood. Something like the query below might work. Take care.
SELECT *
FROM (
SELECT
Vendor
,VendorLocation
,row_number() over (partition by VendorLocation order by Vendor) as rownum
FROM
Vendor
) t
WHERE
rownum = 1
AND
Vendor = 'HP'
Jan 26 2022 10:47 AM
Jan 26 2022 11:24 AM
Hi @Alex_Kim245 --
Would you be able to paste the error message or screenshot of the error that you are receiving? I tested on SQL 2019 and am not encountering any errors. Take care.
Jan 26 2022 11:41 AM
Jan 26 2022 11:52 AM
Hi @Alex_Kim245 --
That query will only work on SQL Server and is incompatible with Access. Unfortunately I do not know the Access-equivalent syntax and do not have Access available on which to test. Take care.