I’ve data like below in a table cryptotransactionledger id transaction_typeid transaction_type amount totalcoins 1 1 bitcoin-credit 30 30 2 2 ethereum-credit 20 50 If I spend bitcoin, I’m putting a new entry like below in the same table with transaction_typeid 3 and similarly for ethereum with tra…
Tag: sql
Rank Date based on today’s date
I have a simple date dimension, I’m attempting to write a Window function (without much luck..) to net the following result. where 1 is today and 0 is yesterday. What can I try next? I’m unsure what to search for. Answer Assuming the dates are continuous, we don’t even need analytic function…
Got an error while executing query {“statusCode”:500,”error”:”Internal Server Error”,”message”:”syntax error at or near “)””}
I have a db with a primary key address I want to write a request that would delete rows that match the address that I pass in the array. I have this in my missing-urls.js file and use this query in my query/missing-urls.js file When I run this request I got an error. What I am doing wrong? Answer You
Query condition where a value is in a comma separated string
I have a table in which one of the table columns third_row stores a comma-separated list of numbers as a string but when its value is A then it means a combination of all the possible numbers. How do I approach this so that the query returns all the rows that have the third_row as A and the rest where
How to insert to a table if there exist a value in another table
i have tried this I want to insert to examqst only if there is a row examid in examname table and s_id in examname have a perticilar value Answer You could an INSERT INTO…SELECT:
Query validation for Amazon Athena using AWS SDK
I am using the AWS SDK to execute Amazon Athena queries using Java and what I would like to do is to have some way of ensuring only SELECT queries are executed. This is to make sure queries like DROP or INSERT are not executed. So is there any way I can perform this check using the AWS SDK without
SQL command not properly ended in Python OracleSQL
I’m having some trouble with SQL code that works when I run it in DBeaver, but when I execute it with cx_Oracle it comes up with the error of: The python code is good, but I’m not much of a SQL programmer, so maybe someone can look to see if there is any obvious coding errors. It’s just weir…
How to decompose the tables for optimal querying
Suppose I have three tables Actor, Movie, Producer with following attributes Actor(Id,ActorName,Bio) Producer(Id,ProducerName,Bio) Movie(Id,Name,Description,ActorName,ProducerName) There can be many actors in a movie and actor can act many movies, same goes with producer. How to effectively decompose/create n…
casting date within a to_char function?
How can I cast a date or timestamp column to date within a to_char function? But I need to cast the date_column to date first but am unsure Thanks Answer TO_CHAR, as you are using it above, appears to be Oracle code. MySQL uses the DATE_FORMAT function:
Select Min() and other columns and GroupBy by two columns in EF 6
Using the example below, (from the answer in this link here) how can I select/group with an extra column ? I have searched this site and others and tried some examples but couldn’t get it to work. Answer It sounds like what you want would be: Then in the .Select() This groups on distinct combinations of…