I have a stored procedure that needs to accept a parameter @pnumber as a string of values like 1001,1002,1003… My stored procedure looks like this: My data: The problem with this stored procedure is – when I input the parameter as (1001,1002) the query produced looks like this: My query should act…
Sum rows not in the top x rows of a group in the table into an “other” row?
If I have a table like the following which is the number of records with a given label grouped by a certain category (in this case Male, Female), How would I transform it into a table that keeps the top x (e.g. 5 records) for each category, when the rows are sorted by number descending, and sums the remaining…
When using an OR operator, will the query return left condition over the right?
I want to return a single row but want one query to qualify the two conditions. For example SELECT * FROM user WHERE admin 100 LIMIT 1 When I query this, will this return the …
SQL how to prevent masking by like statement
I’m dealing with a masking issue with the like statement such that: case when name like ‘PO_UTI_%’ then ‘UTI’ when name like ‘PO_UTI_ADR_%’ then ‘UTI ADDRESS’ when name like ‘PO_OP_%’ …
Do EXTENDED STATISTICS have any influence on INSERT/UPDATE/DELETE in PostgreSQL?
Obviously correctly created extended statistics can have some effect on how effectively does the query planner evaluate SELECT queries when some mutualy dependant data is being selected, but do they …
SQLite searching for user in table
// This returns a count of 1, so the table does exist, and I know the user exists becaue I have just added him in… Int32 tableCount = database.Query(map, “SELECT * FROM sqlite_master WHERE type = ‘…
How to create a Procedure with specific SQL Select Output in Oracle?
I use an Oracle database and currently I have a problem by creating a Procdure which should create some SQL SELECT Outputs. The procedure was successfully completed but I get no output. It is necessary the work with some temporary variables and another cursor? And it is possible to complement the SQL SELECT S…
How to search records using JSON function in mariadb from json array
I am learning JSON function in mariaDB where I have CREATE TABLE IF NOT EXISTS products ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, …
Get all record in each group using group by clause
I have a table like this DepartmentId EmployeeName 1 A 1 B 2 C 2 D 2 E I want the result to be DepartmentId EmployeeNames …
Mysql STR_TO_TIME formatting
My query looks like this: select STR_TO_DATE( CONCAT(MONTH(date), ‘-‘, DAY(date) ), ‘%M-%d’ ) from `subscriptions` But the end result is always records with null columns. What is wrong with this …