Category "sql"

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->

GROUP BY + CASE statement

I have a working query that is grouping data by hardware model and a result, but the problem is there are many "results". I have tried to reduce that down to "

How to solve usng temporary;using filesort using MySQL SELET SELECT UNION SELECT

I have this query: SELECT * FROM (SELECT a.id AS id, a.user_id AS user_id, aa.power * a.amount AS total_power, a.group_number A

SQL Big Query - Add new column to table with query results?

I'd like to take two columns (latitude and longitude) and create a single column with the combined information. The final goal is (a) see if I can gather useful

Sum for a rolling total

I have the following query: select b.month_date,total_signups,active_users from ( SELECT date_trunc('month',confirmed_at) as month_date , count(

How to show generated SQL / raw SQL in TypeORM queryBuilder

I developed typeorm querybuilder. For the purpose of debugging, I'd like to show the generated SQL query. I tested printSql() method, but it didn't show any SQL

Unpivot multiple columns in Snowflake

I have a table that looks as follows: I need to unpivot the Rating and the Comments as follows: What is the best way to do this in Snowflake? Note: there are

JSON object showing null pointer exception

I want to post data to the url and getting Null pointer exception My JSON URL contains { "Details": [ { "Status":"NO UPDATES" }

How to run a SQL query on an Excel table?

I'm trying to create a sub-table from another table of all the last name fields sorted A-Z which have a phone number field that isn't null. I could do this pret

Skip a loop iteration with Firebird 2.5

I need to skip a While...Do loop iteration inside a stored procedure like this While (v_counter <= :v_total) do begin If (<condition>) then continue

Skip a loop iteration with Firebird 2.5

I need to skip a While...Do loop iteration inside a stored procedure like this While (v_counter <= :v_total) do begin If (<condition>) then continue

Joining results from two tables

I have two tables CREATE TABLE person AS ( id INTEGER, sa VARCHAR2 ) CREATE TABLE sampletest AS ( sa VARCHAR2, cell VARCHAR2, pd