Questions tagged [sqlfiddle]

A tool for easy online testing and sharing of database problems and their solutions.

SQLFiddle is a tool for easy online testing and sharing of database problems and their solutions. The project began in January 2012, and was built by Jake Feasel, a web developer originally from Anchorage (Alaska).

SQLFiddle currently supports scripts for the following database engines:

  • MySQL 5.5
  • MySQL 5.6
  • Oracle 11g R2
  • PostgreSQL 9.3
  • SQLite (WebSQL)
  • SQLite (SQL.js)
  • MS SQL Server 2014
  • MS SQL Server 2008

Related links:

140 questions
2
votes
1 answer

How I use a local variable in a SQL fiddle query

I was trying to create a sqlfiddle DECLARE @binsize INT = 5; select 5; select @binsize; <-- this fail. select 6; And got this error. Must declare the scalar variable "@binsize". I have found sample like this and works ok in sql server. USE…
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
2
votes
1 answer

MySQL UPDATE value in SQLfiddle

I've just started on SQL and so far I've made this and it works CREATE TABLE employees(employee_ID int NOT NULL, name varchar(20) NOT NULL UNIQUE, PRIMARY KEY (employee_ID) ); INSERT INTO employees VALUES(1,…
MLMLTL
  • 1,519
  • 5
  • 21
  • 35
2
votes
1 answer

Cannot put INSERT STATEMENT inside TRIGGER body on SQL Fiddle

I have a simple trigger, it runs on SQL Fiddle but it doesn't allow me to move my INSERT STATEMENT inside the trigger's body. my code on sqlFiddle I simply want to move this line INSERT INTO t2(start_date) VALUES (CURDATE()); inside the body of…
Tin Tran
  • 6,194
  • 3
  • 19
  • 34
2
votes
0 answers

Strange results in pivot query

See http://sqlfiddle.com/#!3/c9525/5 strange result in TO FIND OUT MORE ABOUT column row 2 "{ "2": "(null)" }" Targeting both 2008 and 2012, shouldn't it just be null? Is this schema/query correct? Thanks, P.
Pedro Costa
  • 2,968
  • 2
  • 18
  • 30
2
votes
1 answer

Bug in sqlfiddle OR I don't understand INSERT ... ON DUPLICATE KEY UPDATE

This sqlfiddle link seems to retain state across invocations: http://sqlfiddle.com/#!2/125bc/1 It contains this schema for mysql: CREATE TABLE if not exists `standings` ( `teamid` int(11) NOT NULL, `win` decimal(23,0) default NULL, `tie`…
Citizentools
  • 132
  • 1
  • 8
1
vote
2 answers

MySQL-Query for getting a report

I am working on The mySQL database. Here is my DB-Fiddle. Need output like below. I have used the below query select a.product_name as 'Product Name', a.product_model 'Product Model', c.batch_id as 'Batch', b.rate as 'Sale…
Moeez
  • 494
  • 9
  • 55
  • 147
1
vote
1 answer

Inserting characters into an INT field with SQL Server

I've made a fiddle in SQL fiddle and am trying to display a list of numbers 1-99. I also want the numbers to be replaced with text if certain conditions are met. I have implemented the conditions but cannot input text since the column is an INT…
Hassan
  • 61
  • 3
  • 12
1
vote
1 answer

SQL - Calculate percentage after Group by - Only one row is shown

I am fiddling on SQL fiddle with group by clause and finding the percentage based on the temp table "A" result. Here is the fiddle. http://sqlfiddle.com/#!9/faf2f/6959 I did come across that there are different ways of achieving this like by using…
just10minutes
  • 583
  • 10
  • 26
1
vote
1 answer

Whats wrong on my Postgres insert or update query

I want to insert or update data to a table. The column "Group" is UNIQUE and the ID of the group should remain constant. there Is a Fiddle: http://sqlfiddle.com/#!17/551ea/3 on Insert, everything is okay also the Update works for "Group" =…
bear7
  • 11
  • 1
1
vote
0 answers

How do you use table data in an alias for a select statement?

I'd like to reference data from a record in the name that I give the column that a SELECT query returns. I've tried this, but it's not liking the extra SELECT that I'm trying to concatenate into the alias: SELECT Table1.Field1 AS "Pick any " & …
Isaac Reefman
  • 537
  • 1
  • 8
  • 26
1
vote
3 answers

Split Values into several other columns

Code : CREATE TABLE table1 ( day DATE, name VARCHAR(40) ); INSERT INTO table1 (day, name) VALUES ('2018-01-01', 'test1'), ('2018-01-01', 'test2'), ('2018-01-01', 'example'), ('2018-01-01', 'somevalue'), ('2018-01-02',…
rn605435
  • 175
  • 2
  • 12
1
vote
2 answers

How to compare count of columns with each other in group by groups and find the max of them

At first please refer to http://sqlfiddle.com/#!9/7b458/ for the database i have created. ( MYSQL) Now i have a problem to FIND OUT IN WHICH COURSE MAXIMUM NUMBER OF STUDENTS HAVE TAKEN ADMISSION . This is how i proceed select course_name from…
k.dot
  • 23
  • 3
1
vote
1 answer

Table doesn't exist - returns 'Invalid Object Name'

I'm using SQL Fiddle for a project. I built my schema in left panel, everything works out fine and I get the Schema Ready message. When I attempt to perform a Select query on the right table, it tells me the tables I just created do not exist. Here…
Drixisnoob
  • 11
  • 2
1
vote
1 answer

How to load an extenstion of SQLite in SQLFiddle?

In SQLite there are some loadable extensions. How can I load an extension then use it in SQLFiddle? For example I want to load JSON1 Extension then use it for Json fields.
shA.t
  • 16,580
  • 5
  • 54
  • 111
1
vote
0 answers

Cannot add foreign key constraint in SQL

I have been reading through this forum trying to find the right things to solve my question but I cannot find any answers. I have tweaked my code so much to make sure that the issue is really with adding a foreign key. My tables are created before I…
1 2
3
9 10