Category "sql"

How to convert a hash string to an integer in Snowflake?

I'm trying to get a hash of a decimal value and convert it to an integer. But the query results in the following error: Numeric value 'b902cc4550838229a710bfec4

One column group by order value

The table name is "OrderDetails" and columns are given below: | OrderDetailID | Order Value | | --- | -- | | 1 | 1000 | | 2 | 1200 | | 3 | 1500 | | 4 | 2000 | |

MySQL Select query between dates

I have a MySql table called contracts. I try to filter contracts applicable between two dates 2022-05-03 and 2022-05-07. MySQL query must be return id numbers:

How to select all columns except 2 of them from a large table on pyspark sql?

In joining two tables, I would like to select all columns except 2 of them from a large table with many columns on pyspark sql on databricks. My pyspark sql: %

How do I solve multiple joins producing duplicate application_id in sql query result

I have this query below and when I include the last join, I keep getting duplicate applicationid is the query result select distinct a.id, a.applicatio

BigQuery - unsupported subquery with table in join predicate

Recently I started to work on BigQuery and there's something that makes me still confused. What's the alternative for this query on Big Query? select a.abc, c.x

psql: how to exit with error if query returns 'False'?

I'm using psql to check if a table exists in a given database. The command below works fine to return t for True or f for False: psql -U $user -d $db -t -c "SEL

Why does my table join return values I didn't specify?

I am attempting to join two tables to create a visualization that shows the relationship between weight, BMI, and total steps using the following code: SELECT

The Query is not working when I am adding a CTE command to it , although the Inside Select Query is giving the coorect result

In First Image Only Select Statement is run , it works fine . but In Second Image when we added CTE and executed the query , it shows error. Can you please hel

PostgreSQL Can't Convert String to double precision

So I'm asked to do this query for a college project: SELECT l.city AS name, AVG((pr.ap_price::double precision * 7 - pr.weekly::doub

Sum of digits in string SQL

Suppose I have column with strings with digits and non-digits. For example 1a2b~#3c. How can I find sum of the digits in these strings. I can't use CTE and my q

How to multiply 2 tables in SQl

Preface: this isn't homework - I am learning SQL. I was given the problem to make a multiplication chart. Here's my solution: create table x (x int) create tabl

How to select multiple Columns in SQL with inner join

as you can see in my picture i have got an eer-model with 6 tables. Now I want from the table "catalog" the "ItemID", from "Users" the "UserID" and from "Roles

From keyword not found where expected error in oracle

Select firstname as name, time as asof, salary as bal into temp employee from people.person p where p.id =1; Need to create a temporary table employee by inser

DISTINCT with HASH MATCH (Flow Distinct) in SQL Server

Recently, while working in SQL Server, I got an interesting thing that removing DISTINCT keyword actually decreased my query performance and increased my search

SQL customer who never order product p1 and p2 together

I do have two table. I want to find customers who never order product p1 and p2 together(there are million rows in this table) customer_id 2,4,1,4,2,1,3,2,1

How to convert nvarchar to date from one column to another in SQL Server

I have a column called “Month Year Raw” that has multiple nvarchar type data like this: 202201 and I want to convert that to a column called “

MySQL, Concatenate two columns

There are two columns in a MySQL table: SUBJECT and YEAR. I want to generate an alphanumeric unique number which holds the concatenated data from SUBJECT and

How do I execute clob in execute immediate

I have a table with one row and clob as column (whose size is 5239). This column contains a table script extracted with the help of dbms_metadata.get_ddl. Along

Is it safe to store dates as a string in mysql?

I have to allow my users to make an update with 24 hours of delay from their previous update, so because date operations in this case are going to be on the bac