I have tables ‘users’ and ‘user_transactions’ in AWS Athena. The table has many columns but I am interested in 2 columns viz. user name and txn_type. The txn_type column has 3 possible values viz. FT, NFT, PT. For each user, I need to print the count of each transactions in the below f…
Tag: sql
SQL Query, What have I done wrong? I am fairly new to mySQL
Solution problem solution uploaded Answer You have to tell the count() function what to count. You can insert an individual column, or * for all of it etc. But you have to count something. This is a fiddle, showing how it works: https://www.db-fiddle.com/f/dbPnE4BXv8oRRkQY4WQs8v/1
Found the symbol “CREATE” instead of
I don’t know why it gives me this error: Error(3,3): PLS-00103: Found the symbol “CREATE” instead of one of the following: ( begin case declare exit for goto if … I tried using the backslash, but it doesn’t solve the problem, any help? Answer You cannot use DDL statements in PL/S…
SQL | I want to compare a sum of two or more rows and then make a select statement
So I have this table in MySQL: datec.masini So, a proprietar (person unique ID) can have one or more cars with a valoare (value $) and I want to show by a SELECT statement all the persons (proprietar) with cars above 190000$. I tried this but doesn’t work: SELECT proprietar FROM datec.masini WHERE sum(v…
sqlite query based on selecting from column string and filtering by last rows in descending order
I have a database, tick_df, that looks like this I am trying to select all columns and the last 2 rows in descending time order from only one symbol – e.g.AVAX/USD:USD. The query I have tried is But this return an error can anyone point to what I’m doing wrong here. Thanks Answer If you look at th…
How to parse a string and get the value after “=” character
So I have string that should contains “Object.Name” once in a row , if I see it ,I have to get the value after “=” character. If doesn’t match it anywhere in the string i should move hardcoded value. Here is example of the string: I know that I should use case for that but doesn&…
SQL get every hour and minute of day
I would like to create a table with 2 columns – Hour and Minute. Table will store every combination of hour and minute in the day Example: A header Another header 0 1 0 2 0 3 … … 0 59 1 0 1 1 1 2 … … 23 59 I would like to populate the table using Oracle
how to extract and zip values from json with SQL, mysql
I struggle to extract the required values from the JSON column in MySQL. Imagine the variable: and I need to extract and return a new JSON array containing only selected key-value pairs, eg.: only a’s and b’s and if the required key does not exist I want to return null for that key: thanks Answer …
split one column values into multiple column based another column value
could you please help me writing select query to get expected output from the below picture. what I want is to split the UPC column values into three columns(Bottle UPC, Pack UPC, Case UPC) based on its UOM column values ZF2, ZF1 and ZF3 respectively. any help would be appreciated. Thank you! Answer This is o…
Hasura Graphql does not return all documents when multiple foreign keys exist in a table to the same foreign field
Query: Response: Expected: Why are the last two documents not showing up from the first query? Connection table definition: I know this could be more of a SQL question, but it would be great if you can show the graphql version too Answer You have to create two relationships between users table and connections…