I’m counting number of rated calls and average rating in callcenter: (12 rated calls for sales and 4 rated calls for service). I can also count number of total calls (rated and unrated): (21 total calls for sales and 4 total calls for service). But I want to count only unrated calls. SQL request: runs s…
Tag: sql
#1005 – Can’t create table `musicplayer`.`Albums` (errno: 150 “Foreign key constraint is incorrectly formed”)
I’m trying to define some tables with SQL, but when I execute it I have an error. Below there is my code and the error which I receive. CREATE TABLE Artists ( id INT AUTO_INCREMENT PRIMARY …
How do I convert Timestamp (having milliseconds) to EPOCH in Redshift
How do I convert from timestamp (having milliseconds) to epoch For E.g., Using EPOCH gives the same results for both the timestamps, even though they are different timestamps (different milliseconds) Query- I want different results as they have separate timestamps Answer Just don’t cast to bigint if you…
Column concatenation in Order by expression. Is it wrong?
What are pros and cons whether I use Order by expression like this: or in this way: How each one does impact on performance? Answer The concatenation is unnecessary and may produce incorrect results. For instance, consider these values: The concatenation will put the first row first. By individual keys, it wi…
Snowflake BIT datatype
i have BIT data type in sql server and i am trying to migrate it to snowflake but i am not able get the data into snowflake properly 0 goes as 0 but 1 goes into as 255 when i DT_UI1 data type to output the column in sql server can anybody help me how to send bit data type
Get comments per video and total sum of comments per video channel
In addition to Get total sum of video comments for each video I noticed that I can’t use v.commentCount because I cleaned some data and now the column is inaccurate. So I need to count the videoId comments and the total videoID comments with the comment table. I have a table video and a table comments. …
How to check if a varchar contains an upper case char in postgreSQL?
I have another Question comming up, while solving some problems with postgreSQL. Is there any option, to check (in a check statement), if a varchar() contains an upper case character? (I want that my table only holds Strings with at least one upper case letter.) Thats how my table look: Does anyone have a tip…
Moving Data from SQL Server to Excel, Views or Query?
I have an Excel spreadsheet that pulls data from a view (that’s pulling from another view) in SQL Server, this was created by someone other than myself. Due to recent changes in how we are storing data in SQL Server, the views no longer actively reflect the data needed. The current Excel spreadsheet use…
How to set flag value based on data that use one-hot-encoding
I have a database consisting of three tables like this: I want to make a machine learning model in R using that database, and the data I need is like this: I can use one hot encoding to convert categorical variable from t_pengolahan (such as “Pengupasan, Fermentasi, etc”) into attributes. But, how…
How to add parameters to a query when query is unknown length
I am working on a project where multiple rows are needed to be added to a MySQL table, due to the high latency of the connection I am trying to add all the values in one command to save time. So far I have a SQL query that is determined by a string array(each string being a “token”), this, being