I have a table that has 60 columns (and thousands of rows) and it references to 15 catalog tables and 3 of those reference to another 3 catalog tables (the whole database is less than 1 GB). These …
How to make IN on values from cell?
I have table which contains list of data ceparated by coma eg I am trying to left joint it with IN clause, but without success Answer One option uses string functions:
How to use where condition in if statement which is already written in codeigniter
I have got a situation where the $user_id parameter is optional and I used to do this in codeigniter in the way written below. But I am not able to figure it out, How can I write this query in laravel’s eloquent and query builder as well. Any help is much appreciated. Thanks Answer Using Eloquent: Using…
Identifying products that a customer owns
I want to check whether my customer owns an iPhone, iPad, or Macbook. I am not looking for how many iPhone or iPad or Macbook one customer has, I just want to identify if they own any of them, or if they own any two, or if they own all three. I am thinking of using the CASE WHEN function
How can I calculate percentages from total rows and status in sql?
I have a table that contains a list of templates and statuses that I am trying to calculate percentages on. My schema looks like the following: SQL SQL to Create DB Sample Data: What I’m trying to achieve: The query I have so far is the following: The problem I have is that my percentages return nothing…
Mysql – How to create view representing dynamic pivot
I have two database tables customers which contains data about customers with the scheme like that: mysql> SELECT * FROM customers; customer_id created_at partner_id 1 “…
SnowFlake Convert_timezone function format mapping
Problem My 24 timezone codes are like EAT, ICT, NZT and I need to use the SnowFlake Convert_timezone function to convert the American Eastern time to the timezone that the records have. But SnowFlake …
How to use case statement and min() with group by?
The following query when I that execute It seems error ORA-00934: group function is not allowed here I guess , there is error min() in group by. How can I solve this problem? Answer You have to use analytical MIN() function like the below without group by
Query to get the previous value for a group of numbers
I have a table Metadata with columns code,revno and idno. revno will be unique. Same idno may exist for multiple revisions. Now my requirement is, For a set of given revno, I need to query the …
SQL Server 2016 TDE Encryption on big text column
We implemented SQL TDE (SQL 2016) successfully on columns smaller in text size, but will give error on large columns Table Structure ID – value 1 – wanted to confirm her order for the install, adv …