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 …
Using Excel cells as parameters to update a database
I am trying to update an access database using information stored in excel, Below is an example of the cells I will be using: 01234 Past 43343 failed 43743 past This is what I have so far: …
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 …
How to add date and time in SQL Server
I have two variables @date of type datetime and @time of type time. I want to add both to get another datetime variable. And I want to perform further calculations on it. Ex: Declare @date …
select where time = x or later
I have a table with columns username and timestamp . When a username is entered the current timestamp is as well. I would like to fetch the rows of all the new users from a certain time until now, but the start time varies. Lets make it a timestamp represented by x. I would like to use SQL to select
SQL : remove last comma in string
I have a text memo field in SQL table that I need to remove the last character in the field if it’s a comma. So, for example, if I have these rows, I need to remove the commas from rows 2 and 4. The output would be: Any ideas? Answer Using REVERSE and STUFF: First, you want to TRIM your