Skip to content

VBA Runtime Error when connection to SQL Database

I’m trying to connect to a SQL Server from multiple PCs in the same domain. When using the following code: conn.Open returns the error: Error on login for the user ‘XXXX’ Answer The issue is because you are using a named user with Integrated Security. These two modes are incompatible. Try re…

SQL: Filling in Missing Records with Conditional

I need to count the number of products that existed in inventory by date. In the database however, a product is only recorded when it was viewed by a consumer. For example consider this basic table structure: Using the following query, I attempt to determine the amount of products in inventory on a given date…

Select rows which have a field in common with another row

I have two tables: products and postings. A product is a consumer product (ex. iPhone X), and a posting is a listing for a product on an online marketplace (ex. eBay posting). A single product has zero or more associated postings. Is there any way to select only postings which have a “sibling”? ie…

How do i write this without using ALL?

Write a query to find only those customers whose grade are, higher than every customer to the city New York Answer You can use MAX in your subquery instead: As @GordonLinoff points out, if there are no customers from New York, this query will fail. You can work around that by using COALESCE to convert the MAX…

Find diff between three tables

I’m trying to find the difference between three tables, a, b, and c. I’d like to join all three, showing nulls where each table does not have records. Each table has two columns that I would like to …

How to match and fill based on first record in SQL?

Currently have this table here: i have two columns a URL which constantly changes and a url code – I want to take the first URL record and “fill” a new column where the URL_code matches – see outcome …

PATINDEX Number/range of wildcard characters

In regex we have syntax for occurrence of any characters between ‘a’ and ‘b’ that goes like this: /a.{5,15}b/ but we were able to specify minimum of characters between them (5) and maximum (15). Is …