This is my database’s survey table: I learned to use CURDATE() and DATEADD(), so the table can now automatically calculate the survey_date and its expiration_date. But I’d also like to add a value …
Tag: sql
Converting NVARCHAR to INT after SUBSTRING using CHARINDEX and LEN
I am trying to join two tables using UI’s but the UI in one of the tables has ‘CLIENT_’ before it. When trying to remove the ‘CLIENT_’ from the string and then compare the UI’s I am getting the …
Laravel 5.8 / Mysql: Cannot delete or update a parent row a foreign key constraint fails
I am trying to setup my tables in my MySQL database and and I am currently creating migration files using Laravel 5.8. When I run a fresh migration with php artisan migrate all the migrations run …
What is more efficient, few small related tables or one big?
I have information about a Shop. It belongs, to a City. City belongs to the Country. And Country belongs to a Continent. Should I make one big table that contains 4 columns with information about …
Escape single quotes from comma separated string in Oracle
I am trying to escape single quotes from the comma separated string in Oracle SQL Developer, below is my Select query: SELECT (CASE WHEN PS.SUPPLIER_NO IS NULL THEN ‘FALSE’ ELSE ‘TRUE’ END) AS “Check”…
Group by a table then add another tables count into the first table grouped count
I want to group by the First table then add the result of the second and third table with the grouped count… But with a dummy servicecode select servicecode, Count(*) as count from servicerequest …
Using ROLL UP/CUBE in conjunction with PIVOT [Oracle]
I have a table in Oracle that looks like this: year month customer ———————— 2011 Jan Smith 2011 Jan Smith 2012 Feb Howard 2013 Feb Howard … Now I …
How do I get result from SELECT clause after CREATE and INSERT clause?
I have a query that I intend to put into a stored procedure for ultimate use in Tableau. I am getting affected row(s) instead of the grid result. The query is as follows: IF EXISTS #A DUMP #A CREATE …
Store a list of numbers returned by a query into a variable
I’d like to store the Ids returned by a query like so into a variable: SELECT FooId FROM Bar; — FooId is of type int So that I may later say something like: DELETE FROM Foo WHERE Id IN @…
How to compare two snaps of schema data in SQL?
I have two tables: Current_Ranking: id rank 1 20 2 25 3 26 4 17 Previous_Ranking id rank 1 20 2 26 3 18 4 17 5 5 I want to get as a result all records in …