Category "sql"

How can I call a .sql file from R?

I have a rather large query that I am trying to run within my R script. Rather than create a variable within my script ( that raises the error: variable names

SQL: How to generate a unique value for a Primary Key

as the title states. I do have the following table: CREATE TABLE exampleTable( ID int NOT NULL, Text varchar(255), PRIMARY KEY (ID) ); By inserti

MS Access version of a Python melt

Assuming a table organized thus: Row | School | LocationCode2011 | LocationCode2012 | LocationCode2013 001 ABC 1000A 1000B

Insert of records into SQL Server is slow whereas select is quicker

I am trying to improve the performance of insert in SQL Server. INSERT INTO [dbo].[GroupCustomerAccountProductRebates]([GroupId],[GroupName],[ProductId],[Manufa

SQL Error [1064] [42000]: You have an error in your SQL syntax while running query

While I am trying to select a table on a MySQL data base, I am getting the following error: SQL Error [1064] [42000]: You have an error in your SQL syntax; chec

Multiple INSERT INTO statements not working in dbeaver

I am trying to insert data into a table and I have written multiple Insert Into statements but I am facing an issue which is quite strange. When I run whole scr

Iterate through a list of servers in SQL Server

I have a script similar to below and get: Could not find server '@CURSERVER' in sys.servers. Verify that the correct server name was specified. If necessary, e

SQL: STATUS column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause [duplicate]

Hi Just want to GROUP BY my table without using the status column. but I keep getting the error and I can't figure out to resolve it. SELECT *

Update column "total price" in orders table using other columns (pizza_price*pizza_amount) in different tables?

This is relational diagram of database I created: I need to insert total price in Orders.Total_Price column by multiplying the Pizza.Pizza_Price value with Ord

How do I return single orderid having same rank?

I have the following output: Orderid Time State Order_rank 1 10.15 mfr 1 1 10.15 delivered 1 2 12.10 picked 1 2 12.10 mfr 1 Here I have ranked the order ids w

how to pass asc desc as params in python psycopg2 raw sql execution?

i have a sample query template to accept dynamic parameters to execute: ps_conn = psycopg2.connect(...) ps_cursor = ps_conn.cursor() ps_cursor.execute(''' S

Attempt to read from field 'android.view.View androidx.recyclerview.widget.RecyclerView$ViewHolder.itemView' on a null object reference

I am making an app that gets data from sql and puts it in a recycle view i first tried it in a list view but i found it easier in a recycle view it is basically

Remove duplicates from SQL Window function

I'm trying to sum values inside a window function but I can't figure out have to prevent summing duplicates. Below is a snippet of the results I have right now.

SQL - Find customers who bought all products

Suppose I have 2 tables: Table A C_ID P_ID 1 1 1 2 2 1 Table B P_ID 1 2 In Table A, C_ID and P_ID serve as PK, in Table B P_ID

Convert string date format MM/dd/yyyy HH:mm:ss.SSSS to timestamp presto

I have a string that looks like: 2022-03-30 17:18:09.569000 I am trying to convert this to a timestamp as follows: select "date_parse"("date_format"('2022-03-3

Find syntax error IN SQL query using python

I want to parse sql file using python code and find any syntatical error present in the file. Is there any way to do it?

How do you extract a specific field from a JSON array in Big Query?

I currently have a JSON array that looks like this in Big Query: [{"name":"","username":null},{"name":"Jimmy Dean","username":"iamjc"},{"name":"Ben Simmons","us

Collapse multiple rows into a single row based upon a break condition

I have a simple sounding requirement that has had me stumped for a day or so now, so its time to seek help from the experts. My requirement is to simply roll-up

What is wrong with this inner join sql query

I want to export some data from the DB. Basically what I want to say is this: 1- Select mbr_name from the members table 2- Choose the ones that exist at the cou

Snowflake SQL Compilation Error: View Definition Declared but view Query Produced

I've just gotten a new query error that I haven't changed anything to. Any advice on what to do? Thanks SQL compilation error: View definition for '**********'