Category "sql"

How do I recursively select rows where values in one column are present in another column?

I have a table like below with two columns Person and Supervisor. Person Supervisor 1 3 2 3 3 4 I want to select rows where the Supervisor column only has val

Is there a way to return collection instead of entity in @Repository's @Query

I have a query: @Query( value = "select name, age, now() from received.scheme ;", nativeQuery = true ) public {???} selectData() I cannot create or r

What is the data type in ASP.NET Core for decimal(18,2) in sql

I have a Amount column in database which is in Varchar datatype, I am retrieving the data from table and I am casting for the amount should be returned as (123

Symfony doctrine specify fields in ManyToOne to improve performance?

For example i have a simple entity "Cars" with a ManyToOne relation "Brands". class Brands { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\C

Lookup value in Query

I'm trying to replace the local variables i've declared below to capture them in calculated columns. So the [YTD] column would look up Today's Date - 1 and retu

Learning MySQL with PopSQL and wanted to carry on with a tutorial but I cant connect to my database. Error 1049 No connection

I opened PopSQL and the there is a red dot at my connection. If I go into it and test it, it tells me Unknown database 'giraffe'. I opened mySQL and typed 'show

SQL query how to find the average number of rental books for each quarter

I am trying to find the average number of rental books for each quarter. Rental(RegNum, DateBorrowed, DateReturned) Books(RegNum, BookName, Category) What i am

How to convert iso 8859 string to UTF8 in a postgresql 12 database?

EDIT : I think I was not clear, I am sorry for that : I have a column with bytea data. This column, when I apply encode(column,'escape') to it, I got text in th

How to build a nested array result from self referencing table

I have a db where a foreign key references my primary key, Ill like to select all rows where the foreign key is NULL and then add rows with a foreign key as nes

SQL Join tables - join with last four digits of columns

I'm trying to join two tables in SQL. I want to join on the column with the last four digits of a phone number with the a column from a second column where only

Smallint stayed null after executing update SQL statement in Sybase

The DB was Sybase. I executed update SQL statement like UPDATE table_name SET smallint_col = 0, datetime_col = CONVERT(datetime, '1999-09-09') WHERE some_col =

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 *