Category "sql"

Pivot rows into columns Firebird 2.1

I have a table containing several kilometers about 100 table of kilometers I need to rotate rows into columns like this pivot rows into columns The number of co

Distinct and List of other column in postgresql

I am using postgres DB and i have table with two column name and sal . name Sal Raunak 10000 Raunak 5000 Rahul 500 Raunak 300

What kind of query optimization can be expected?

tl;dr; Will the query optimizer be able to optimize the max calls? select id , max(case when this and that11 and that12 then 1 else 0 end) name1 , max(c

SQL If Value Exists then return that otherwise return whole table

Note: This is an over simplified version of what I am trying to do. Let's say I have a table called USERS that has FIRSTNAME, LASTNAME. Contents are: JOHN SMI

How to get the top 1% of soloists calculated by the total number of concerts performed

I'm working on this sql challenge, but I don't know if the way to get the top 1% of soloists calculated by the total number of concerts performed. is correct. P

Dependent dropdown using WHERE clause

I am looking for some help. I need to create a dependent dropdown based on the previous input. Everything works in my code, and it sends and receives data from

Sorting and getting position or row nth number of sqlite database for Android studio

I have this table of students public void onCreate(SQLiteDatabase db) { String createTableStatement= "CREATE TABLE " + STUDENT_TABLES + " (" + ID_COL + "

Select max value from table by category

Bought X times Name Manufacturer 19 Олівець Faber-Castell, Castell 9000 F FaberCastell 14 Наб&#

How to feed PARTITION clause dynamically in ORACLE?

I need to know if it is possible to feed the PARTITION clause with the latest partition name of a table, instead of using his value. Normaly we have: SELECT *

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