Category "sql"

Oracle SQL | Auto incremented ID is not incremented when an id is provided

I have following incrementing id: create table PATIENT ( PATIENTID INTEGER generated by default on null as identity ( start wit

Query the two cities in STATION with the shortest and longest CITY names, [closed]

Query: Query the 2 cities contained in STATION table with the shortest and longest CITY names, as well as their respective lengths (i.e.: numb

DB2 SQL Statement WHERE clause CASE WHEN in multiple conditions

This is what I am trying to do: SELECT id, name FROM users WHERE isActive=true (AND CASE WHEN {param} != null THEN name={param} ELSE null E

How to update record with the same data of existing record

How to update record many columns with the same data of existing record in the same table . For Example : id name m_value 1 moh 1000 2 jo 0

Conversion failed when converting the ****** value '******' to data type ******

I'm getting this error from SQL Server on SSMS 17 while running a giant query: Conversion failed when converting the ****** value '******' to data type ****

"IN" clause limitation in Sql Server

Does anybody know what is the limit for the number of values one can have in a list of expressions (to test for a match) for the IN clause?

Postgresql ERROR: cannot drop columns from view

I'm new to postgresql. Can anyone suggest the reason and solution to this error? However it works if I select an extra sum(s.length) but i don't won't this in m

PostgreSQL: encoding problems on Windows when using psql command line utility

I'm working in a centralized monitoring system on Windows 2008 R2, I have installed a PostgreSQL 9.3 to use psql from the command line. When I try to access to

prevent escape string c#

I have my sql query which displays fields using "where" from a variable. I have my variable passed from a function string empCode which value is "!\\(" Here's

how to validate date null in mysql?

I'm working with MariaDB. when I try to show some result don't show me nothing. select if(fecha is null,'hello','bye') dat from table I'm trying to

Restrict user-defined T-SQL query to SELECT type only

I am working on an app that is providing a way for an user to define a SQL query and run it against the database. The only purpose of the query is to create a d

Transpose One Column From Multiple Rows in to Multiple Columns in One Row

I am working with healthcare data that comes from a table that only has one column for procedure code billed, but multiple lines of transactions for each claim

How to get the latest message in each conversation of a certain user in SQL?

I need to write a query that returns the latest message in a conversation between two users. I've included the schema and my (failed) attempts in this fiddle: h

How to sum multiple hour : mins in sql?

i need to sum this varchar values. time 1 = '13:06' time 2 = '18:59' time 3 = '14:49' i tryed this. SELECT convert( char(8), dateadd( secon

Set SQLAlchemy PickleType Column Size

I am trying to save a python list to an SQL table in a PickleType column which is defined in the class object as text = Column(PickleType). When I try to commit

Update SQL server local table column from linked server table

I have local and a linked server tables in SSMS local [Arc].[dbo].[Record] linked server SQLSERVR.[ArcReport].[dbo].[RecordRemote] when I query select * from [

Difference between sparse index and dense index

I am very confused to understand the difference between sparse index and dense index. Can you explain the difference between them ?

SQL query to check if a name begins and ends with a vowel

I want to query the list of CITY names from the table STATION(id, city, longitude, latitude) which have vowels as both their first and last characters. The resu

How to concatenate columns in a Postgres SELECT?

I have two string columns a and b in a table foo. select a, b from foo returns values a and b. However, concatenation of a and b does not work. I tried : sel

WordPress Subquery returns more than 1 row on SELECT

I am executing this query with core cron by custom Wordpress plugin: // MAKE SQL CALL $SQL = "SELECT ".$wpdb->prefix."postmeta.post_id FROM ".$wpdb->