Category "sql"

Making a MySQL COUNT query

after 4 days of tries and researchs over the web I can't make my wishes working. Any help would be appreciated !Performed on MYSQL WORKBENCH I got a DB made of

Oracle : Use of CURSOR%FOUND in PL/SQL

I have a code as follows. My question is - why do we need IF statement for CURSOR%FOUND ? If no rows are found, that will trigger NO_DATA_FOUND condition and co

Improve insert performance for a C# application into SQL database

I need to improve the performance of my insert in my C# application. I first go out and get data from a view. Then I go through a FOREACH loop to insert into a

SQL Server Trigger After Insert is Repeating old valus

Can someone please explain why this trigger would start failing and insert the same record repeatedly? It seems as though there is something wrong with the vari

collaborating address columns from multiple tables into one column (3million rows)

I have a table that looks like this common_id table1_address table2_address table3_address table4_address 123 null null stack building12 null 157 123road stree

SNP_SESSION Table shows value null in ERROR_MESSAGE column

I tried fetching error message from the snp_session table in ODI 12C. I have explicitly inserted erroneous data in order to get an error. But that error is not

SQL Optimization: multiplication of two calculated field generated by window functions

Given two time-series tables tbl1(time, b_value) and tbl2(time, u_value). https://www.db-fiddle.com/f/4qkFJZLkZ3BK2tgN4ycCsj/1 Suppose we want to find the last

SQL Server combine case with convert statement

Hi im stuck with this query, what i want is to get one column "fecha_registro_convertida" with the condition of the case statement but also with the CONVERT sta

Does it matter to filter results when doing aggregation?

I want to get my sales for each day which is located in my orders_summary table. orders_summary table columns: id, date, amount, sku_id products table columns:

Retrieve the last value of each data group - Oracle SQL

I’m having trouble on a query right now to retrieve only the last value saved for each group of results. I explain myself with a table. I have these value

Create table from simple UNION statement

What is wrong with this union? first 'select' and ')' are incorrect create table GL_ALL ( select *from GL1 ) UNION ( select *from GL2 ) UNION ( select

Oracle SQL - table type in cursor causing ORA-21700: object does not exist or is marked for delete

I have problem with my function, I'm getting ORA-21700: object does not exist or is marked for delete error. It's caused by table type parameter in cursor, but

How do I create a table with multiple auto incrementing values?

I would like to have an autoincrementing string in my BigQuery table. This seems like a good way of doing it: CREATE TABLE dbo.YourTable ( ID INT IDENTITY(1

How to Generate Date Series in Redshift?

I would like to generate a sequence of dates in Redshift. I can easily do it in PostgreSQL using the generate_series() function. This function works in Redshift

How to sort one column and then another within it in SQL? [duplicate]

I have this table state num ------------------------- ca 20 ny 30 ca 50 ca 10 ny 70 ny 90 What I want is to p

Update all affected rows with specific values on PostgreSQL

I have the simplified version of the table I have below. Each row has an item_order value partitioned by its parent_id. item_id item_name parent_id item_order

PostgreSQL Crosstab Query

Does any one know how to create crosstab queries in PostgreSQL? For example I have the following table: Section Status Count A Active 1 A

C# SQL query with user input

I tried to make software that could be use as a database for libraries so I started to learn SQL I alredy did way to save a book into the database but I am stuc

mysql null value case when is null does not work

I have following query to handle null value and flag those based on two table join however c.pure_proc_flag is null then 0 else 1 does not provide the result

Unpivot/Transpose in Presto SQL

I have a dynamic table in the format shown in the image (left hand side). A new month column will be added every month. How do I unpivot month in Presto? I can