There’s a plugin called SQLUtilities that will format your SQL nicely; however, it’s really bothering me that it cannot put a column on it’s own separate line: The result that I want is this:
Tag: sql
Postgresql: In-Row vs Out-of-Row for text/varchar
Two part question: What is Postgresql behavior for storing text/varchars in-row vs out-of-row? Am I correct in thinking that with default settings, all columns will always be stored in-row until the …
SQLite not selecting date
My SQlite database in my app stores the date in the format of yyyy-MM-dd HH:mm:ss. I want to query a transaction that happened on a certain month of a year but my code is not working : Answer After some research I discovered that for some reason I had to do some casting for it to work.
SQLite – How to perform COUNT() with a WHERE condition?
I have a products table with these fields: _id, product_name, priority and shelf_id. And I have a shelves table with these fields: _id and shelf_name. Currently, I have this SQL which returns a resultset showing the name of each shelf along with the number of products within each shelf: What I am trying to ac…
Migrating from Oracle to MySQL. VARCHAR2 length defined using bytes. How to port?
I have variable in Oracle procedure declared like this: myMsg VARCHAR2(256 BYTE) How can I port it to mysql? Because this when I try to declare it in MySQL procedure: DECLARE myMsg VARCHAR(256 …
How to run .sql file in Oracle SQL developer tool to import database?
I have exported database from Oracle SQL developer tool into .sql file. Now I want to run this file which is of size 500+ MB. I read about running scripts here, but I didn’t understand the way. Is …
Select rows where the string in one column is an extension of a string in another column
The question: Find the capital and the name where the capital is an extension of name of the country. Note that the capital must be longer than the name (Mexico-City compared to Luxembourg) This is my work, but it’s incorrect Answer To get the extension you can use REPLACE function which in following qu…
Storing ‘Rank’ for Contests in Postgres
I’m trying to determine if there a “low cost” optimization for the following query. We’ve implemented a system whereby ‘tickets’ earn ‘points’ and thus can be ranked. In order to support analytical type of queries, we store the rank of every ticket (tickets can …
Query to sum sales totals for X number of months given dates
I would like to make a query that SUMS the total number of sales of each product ID for a group of months (ie. May – August) I want: +————+————————-+——-+————–+—…
Group rows of data from table based on a column
I want to achieve the below using SQL can anyone please help: TOP BOTTOM Rocksymbol 0 5 l 5 10 l 10 15 ml 15 20 ml 20 25 …