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…
How to duplicate rows generating dates between Start Date and End Date in BigQuery?
I’m having a question on how to duplicate rows in a table that generates dates between StartDate and EndDate. Actually, I have a same question as this Duplicating records to fill gap between dates in Google BigQuery but with a different type of table. So, my table looks like this: and I would like the o…
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…
Select duplicated values from one coloum and get there value in one row
i have table with 2 columns like below I want to select all values from table but view it like below: Answer If you’re not trying to create extra columns in your output, you can simply use GROUP_CONCAT with the separator of your choice. For example: Output: Demo on dbfiddle
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…
How to pull the latest records added in a table?
I want to pull the records associated with the latest VERSION_ID. FILE_EXTRACT_VERSION table looks like this: FILE_EXTRACT_VERSION_SPECS table looks like this: I want to write a query to pull records with the latest VERSION_ID (latest can be segregated by the latest date they have been added) Here is what I h…
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 …