Category "sql"

Check if a number is prime or not in mysql

I am wondering what's the best way to check whether a number is prime or not using sql. I was able to generate the sequence of numbers from 1 to 1000 but I woul

Is there a way to search one table for certain values, and if successfully found, then update a different table?

Good afternoon all, This is my first time using SQL, so forgive me for being new. I have three different tables that I've created: CREATE TABLE employee (ID int

How do I produce a new column with values based on a Partition of one column while also based on the values of two additional columns (BigQuery)?

I have a table that records all the different statuses for a list of Jobs with timestamps. So the ID column has many Ids that appear several times as their stat

GBQ Transpose Dynamically without Execute Immediate

Hi All trying to figure out a way to transpose data in columns dynamically. In the data the distinct number of Traits will increase/decrease. I know I can hardc

Smarter SQL UPDATE between two tables (bill and bill rows)

I have these two SQL tables: Bills (BillId, Folio, Date, ProductId) BillsRows (BillRowId, BillId, ProductId, Lot, Quantity, Price) ProductId is optional in Bil

Target row updated by multiple source rows

UPDATE tb FROM Table1 tb, ( SELECT oreplace(data, '.', '') AS data FROM Table2 ) tb2 SET column = 'Y' WHERE tb.column1

Cannot connect to SQL Server except with domain admin account

I am running into an issue where my .net application (C#) will not connect to SQL Server when ran by a domain user. Exception is: The underlying provider faile

On delete cascade on foreign key not working [duplicate]

I am doing a TODO list app and I'm trying to delete a list and every task which has the referencing listID.The problem is that on delete casca

Hive SQL regexp_extract (number)_(number)

I'm new to hiveSQL and I'm trying to extract a value from the column col_a from the data df which is in this format: \\\"id\\\":\\\"101_12345\\\" I only need to

How to order by many to many relationship in Sequelize?

I have a many to many relationship between User and Category through UserCategory as below. let user = await User.findAll({ where: { id: req.query.user

width_bucket not returning buckets of equal width

I'm using Postgres version 9.6.9 and attempting to use width_bucket() to generate a histogram with buckets consisting of equal widths. However, the query I'm us

REGEXP_EXTRACT in Impala

I am trying to figure out how to extract customer ID from string that looks loke this: {"param":"success","value":"10","level":"0","error_code":"101","customer

get the name of product with the maximum number of orders

I have 2 tables orders and product as orders has only one field (order_id) and the products have a reference to the order_id, how to get the name of product wit

Visual FoxPro 9. Set Grid.RecordSource to the result of SELECT

I have 2 grids and 2 tables. I want the second one to display elements that are related to the selected enement of first grid. This can probably be done in 2 wa

Find average and then use that value to calculate other values

I have a query with a few columns. I need to find the avg of a particular column and then use the average value to calculate other values. I am finding avg with

Nesting json_agg() inside json_agg()

I have these 2 tables tasks and subtasks with these columns: Tasks id name description Subtasks id name description task_id I'm trying to do a query that would

How can I get a React application to send SQL queries to an Oracle database and retrieve results?

Background: I need to create a web application that connects to an Oracle database hosted by my university through a VPN. The app does not have to be hosted onl

Select query where exists intersection of two list

I have one table that contains two columns: id (integer) list_colum (longtext) - contains json array (e.g. [1, 2, 3]) I want to select all records that have an

Unfindable SQLite Syntax Error

I'm trying out statements for creating a database, and after 10 entities without any issues I ran into this error Error: Near line 83: near "Transaction":

Better way to remove HTML tags in Oracle SQL

I have a comments column and the comments added to release are stored as rich text in comments column. Now i'm trying to process this data and get an human read