I was using the starter dataset SurrealDB supplied and working with the daily_sales table. The goal was to query the table and format the result to show the best_sales and best_day grouped by the month_year. While I was able to use the <datetime> casting to format the string into dates and find the max value of the sales to find the best sales in the month, it appeared that finding the day when the best sales happened seemed trickier. I need to equate the result of the grouping sales to the individual days of each sale from the initial daily_sales table. Using a subquery when building the table out in the SELECT clause would not retain the aliases from the main query.
How to use an alias in a subquery in SurrealDB?
120 Views Asked by Jesse Benjamin Slomowitz At
1
There are 1 best solutions below
Related Questions in SQL
- SQL schema for a fill-in-the-blank exercise
- Hibernate: JOIN inheritance question - why the need for two left joins
- What's supposed to be the problem in this query?
- Compare fields in two tables
- How to change woocomerce or full wordpress currency with value from USD to AUD
- Dynamic query creation with Array like implementation
- SQL query to get student enrolled in this month in a course - Moodle
- SQL LAG() function returning 0 for every row despite available previous rows
- Convert C# DateTime.Ticks to Bigquery DateTime Format
- Use row values from another table to select them as columns and establish relations between them (pivot table)
- SQL: Generate combination table based on source and destination column from same table
- how to use system's environnement variables in sql script
- PHP fetchAll on JOIN
- Multitable joining in Sql
- How to display name starting from 'z' by using BETWEEN cmd only?
Related Questions in ALIAS
- How do I separate emails (from 1 alias) in Thunderbird from invasive websites on Firefox with file browsing scripts? Should I worry?
- Using Aliases in a Javascript Function
- Python unexpected non-zero returncode when checking alias command set in .bashrc file
- Creating aliases for Github Copilot CLI (ghcs, ghce not recognised)
- procedure/alias [a portion of] a somewhat long MySQL command?
- Understanding class importation and alias management in Laravel 11's new directory structure
- Drupal 9 contextual filter on url alias
- How to access the previous value of text in Cypress that you expect to change?
- How to time how long a bash alias took to execute (solved... maybe?)
- SQL query in Oracle to sum up values from an alias column
- Microsoft GraphAPI - behavior with emails received from alias email addresses
- How to Alias `python` to Python 2 (`/usr/bin/python2`) on WSL Ubuntu?
- How do I tell the Jackson JSON deserializer to prefer one field over another when both are present?
- Replace dataframe with its alias in select in pyspark
- Error: vite build in github actions - for using aliases
Related Questions in SURREALDB
- How I can use live surrealdb queries in python
- Aggregate relation value group by relation out in SurrealDB
- How to call functions using the HTTP API and pass them JSON objects as parameters
- Create record link using the HTTP API
- How do I connect Surrealist Query (Desktop) to a file stored DB on Windows?
- Specify number of hops(recursive query) when selecting graphs in surrealdb
- Is it possible to fan out arguments passed with .bind() when doing a RELATE query (Rust SDK)
- how to sign in and get authorization for multiple scopes
- Difference of pre computed tables in SurrealDB and SQL-Views when deleting an element?
- Surreal DB REST API
- Embedding SurrealDB in Rust with its HTTP API
- 502 Bad Gateway when connecting to SurrealDB on Google Kubernetes Engine
- IAM error when authenticating with token SurrealDB
- SurrealDB indexes for INSIDE
- unexpected argument '-c' found
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It appears that creating the table within the
FROMcause did the trick of being able to use the aliases and also use the$parentvariable name.My final result is this:
I used
valueandonlyto return a single value without any array. The$parentpreset variable helped retain thebest_salesvariable when compared to the originaldaily_salestable.The final result looked like this:
Link to GitHub Discussion (copied from there)
SurrealDB document on params
Github Discussion on using the
$parentvariable correctly