Category "sql"

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

Group returned result by mysql

I have the following table table x labref name repeat_status 111 L 1 111 L 1 111 K 1 111 K 1 111

How to avoid multiple function evals with the (func()).* syntax in a query?

Context When a function returns a TABLE or a SETOF composite-type, like this one: CREATE FUNCTION func(n int) returns table(i int, j bigint) as $$ BEGIN RETUR

Excel drop down values from a SQL Server source

I am trying to get a cell drop-down values in Excel from a SQL Server. I don't want to use the method of putting all the data to another sheet and the use data

Selecting values from column defined by aggregate function

I'm currently struggling with a query and need some help with it. I've got two tables: messages { ts_send, message, conversations_id } conversations {

Efficient way to edit the last line of a text file in Python

I have a Python script which creates a large SQL insert file of about 300,000 lines. The problem with this is that the last line of the file ends up looking lik

Test for Upper Case - T-Sql

All, How can I check if a specified varchar character or entire string is upper case in T-Sql? Ideally I'd like to write a function to test if a character is u

Using Associative arrays

I'm trying to access a position of a associative array which is inside of another array. Here is my array: Array ( [order_data] => stdClass Object

Query to order by the last three characters of a column

Query the name of any student in STUDENTS who scored higher than 75 marks. Order your output by the last three characters of each name. If two or more students

Return to default value after field equals zero

So I need help in trying to make a database field where it's default 7 and each day minuses 1 until its 0 then the day count starts again from 7. Is it possible