I have a sql table that stores the daily prices of stocks. New records are inserted every day after the market closes. I want to find the stocks that have consecutive increases in price. The table has lots of columns, but this is the relevant subset: The quoteid column is a primary key. In the table, the clos…
How can I select from list of values in Oracle
I am referring to this stackoverflow answer: How can I select from list of values in SQL Server How could something similar be done in Oracle? I’ve seen the other answers on this page that use UNION …
SQL writing format
I would like to inner join to tables with sql like this: $check_unscored = “select * from [user] INNER JOIN [tenderrc] on [user].[id] = [tenderrc].[userid]”; $…
SQL Statement to create a table as a result of a count operation?
Let’s say you got a table like this id terms 1 a 2 c 3 a 4 b 5 b 6 a 7 a 8 b 9 b 10 b and you want to end up with …
DB2 Date format
I just want to format current date into yyyymmdd in DB2. I see the date formats available, but how can I use them? http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm….
Use SQL Server recursive common table expression to get full path of all files in a folder(with subfolders)
There is a SQL Server undocumented extended stored procedure called xp_dirtree, which can return all files and folders name (include subfolders) in a table format. To practice my understanding of …
tSQLt fails when attempting to FakeTable a synonym table
I am using tSQLt (through Red Gate’s SQL Test version 1.0.0.455). tSQLt is installed on database A. I am trying to do a tSQLt.FakeTable on a table in database B on the same SQL server instance through a synonym on database A. Code: ALTER PROCEDURE [ErrorType109NonTankHasSizeOrVolume].[test AliasTest] AS…
Most recent datetime column and count for each table
I have a DB that has 1000+ tables. 100 of those tables are prefixed with a three letters (let’s say ‘ABC’) Only half of those prefixed tables have MODIFIEDDATETIME column. I’m trying to do a simple select query to get all the last updated MODIFIEDDATETIME stamp for each Table that actu…
sp_MSforeachtable – parsing of dynamic sql
I recently found an issue whereby I wanted to use the sp_MSforeachtable stored proc to select all tables with the word Transcode in the table name, and to run some SQL on those tables. I managed to write some code which worked, but not perfectly – for those tables which I’d hoped it would graceful…
CREATE TYPE on MySQL
I couln’t create a new data type on MySQL. Query is given below How can I do that on MySQL Answer You cannot. MySQL doesn’t have user-defined types. (At least, not in current versions.)