Category "sql"

How to add a select all option in a sql databricks parameter? Or if the parameter value is null make it select all?

So I want to create a select all button in a parameter. The actual parameter has around 200 options because of the size of the database. However, if I want a ge

Can't select column name from Eloquence database that has a forward slash in it (from a linked server in SQL Server)

My SQL Server instance has a linked server to an Eloquence database. I need to select data from one of the tables in the Eloquence database, but I need to do i

How do I select the count of records, then group them by a foreign key?

I have two tables: Products and Suppliers. SupplierID is a foreign key in products table. I need to make a table that contains country, supplierID, company name

what does this error mean "column used in NATURAL join cannot have qualifier"

After executing the code below, i get an ORA-25155 error SELECT p.prod_id, prod_name, prod_list_price,quantity_sold,cust_last_name FROM products p NATURAL JOIN

View created in SQL Server Management Studio but not visible in "Views" section

I created a view in SQL Server Management Studio 18 and I am getting the following message: "Commands completed successfully." which I guess means that the view

converting string to date using TO_DATE for MM/DD/YY gives wrong values for dates before 1970 [snowflake-cloud-data-platform]

Trying to convert a date string 03/31/69 to 1969-03-31 standard date format using TO_DATE function. SELECT TO_DATE('03/31/69', 'MM/DD/YY'); Expected value was

PostgreSQL ORDER BY with VIEWs

Let's say I want to write a simple SELECT query that uses a VIEW: CREATE TEMP VIEW people AS SELECT p.person_id ,p.full_name ,p.phone FROM person

How do I do multiple CASE WHEN conditions using SQL Server 2008?

What I'm trying to do is use more than one CASE WHEN condition for the same column. Here is my code for the query: SELECT Url='', p.ArtNo,

Issues with SQL Server and PYODBC

I'm getting an error at this statement: cursor.execute("SELECT * FROM dbo.User") Error: pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driv

SQL formula to match all words in any order in just one statement

I would like to have a SQL formula to match all the words in a query in any order without using multiple 'AND like' statements. For example, the query 'cat dog

#1062 - Duplicate entry '_site_transient_timeout_theme_roots' for key 'option_name'

I'm migrating a site from Site5 hosting to InMotion Hosting and the importation of the mysql file (via phpMyAdmin) is not working. import of mysql file failed,

SQL: Count more than average HAVING vs. WHERE

I had a fairly straightforward interview question: return all countries that have more customers than the average number of customers of all cities. country ta

How can I delete rows from table A and table B if rows in table B don't exist

I have 2 tables and I need to delete rows from both tables if A.itemID does not exist in table B I've tried doing : DELETE a,b FROM A a, B b WHERE NOT E

How to remove reverse duplicates from a SQL query

Context: I have a select query where I have have link between devices. Some links have "reverse duplicates" that I would like to get rid of in the select query

SQL group by: select value where another column has its min/max

I want to group by one column, get both min and max of a second column, and (this is the tricky part!) get the value from a third column where the second column

django test app error - Got an error creating the test database: permission denied to create database

When I try to test any app with command (I noticed it when I tried to deploy myproject using fabric, which uses this command): python manage.py test appname

MYSQL rotate a returned data

I'm getting a data that return like this: | id | name | | 1 | customer1 | | 2 | customer2 | | 3 | customer3 | | 4 | customer4 | Now I want to rotate

Entire Union query returns no results if part of it returns no results

I've created the folllowing Union query, which works fine most of the time: SELECT [%$##@_Alias].[Contact ID], [%$##@_Alias].[Mailing Name] FROM (SELECT [Refer

SQL Transpose Rows to undefined number of columns

I have a table containing graduate ids, degree titles and graduation years. The table can contain any number of rows for each graduate. I would like to create

Oracle SQL query to convert a string into a comma separated string with comma after every n characters

How can we convert a string of any length into a comma separated string with comma after every n characters. I am using Oracle 10g and above. I tried with REGEX