Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Retrieve Top 3 Highest and Lowest Revenue Menu IDs
/ 25
Join Tables to Retrieve Menu Item Names
/ 25
Format the total revenue column to two decimal places
/ 25
Fix the error and retrieve the top 10 small menu items
/ 25
Retrieve Top 3 Highest and Lowest Revenue Menu IDs
/ 25
Join Tables to Retrieve Menu Item Names
/ 25
Format the total revenue column to two decimal places
/ 25
Fix the error and retrieve the top 10 small menu items
/ 25
Imagine you are a data analyst and have been with Data Beans for a few months. You have worked on a few successful projects with your teammates and have been assigned your first solo project. You are starting to create more complex queries with little help, but you have been asked to write more complex queries to retrieve deeper insights. Everyone on the team is helpful, but you need to start showing that you are more self-sufficient in your work.
You have read that BigQuery SQL code generation, explanation, and transformation may help you to write more complex queries using natural language. And, if you get stuck with writing a new query, you have also learned you could use Gemini to help review and debug your code. It could even help you with suggestions to resolve issues. Using these features will help you to be more independent in your work and, perhaps, even more efficient. However, you are not sure how to get started.
In this lab, you learn how to perform the following tasks:
Finally, you have time to reflect on what you have learned in this lab and consider how you could apply the code generation, explanation, transformation, and suggestions with your data, use cases, and workflows by answering questions in your Lab Journal.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:
Note that the lab timer is located near the top of the page, showing the remaining time.
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab setup and access panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab setup and access panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
In this task, you review the menu and order_item table schemas.
In the Google Cloud console, on the Navigation menu, click BigQuery.
Click Done on the Welcome dialog.
In the Data Explorer pane, expand the coffee_on_wheels dataset.
Expand the coffee_on_wheels dataset. You see the menu table.
Click the menu table. You see the menu schema displayed.
Review the details of the schema and answer the following question:
Which fields use FLOAT as the data type?
order_item schema displayed.Review the details of the schema and answer the following question:
Which fields use INTEGER as the data type?
In this task, you generate a SQL query using a natural language prompt to find menu IDs and total revenue for the top three and bottom three items in the menu by total revenue.
Click SQL query () to create a new SQL query. A new tab is displayed in BigQuery Studio.
Click SQL generation tool () to access the SQL generation tool. You see the Generate SQL with Gemini dialog appear. You can enter a natural language prompt in this window to generate a new SQL statement.
Enter the following prompt:
Click Generate. You see Gemini create a SQL statement similar to the following:
Select the query.
Click Gemini () next to the query.
Click Explain this query. The Gemini pane opens in BigQuery Studio.
Click Start chatting. You see an explanation for the query in the chat window.
Review the explanation. Gemini provides a summary of the response similar to the following:
Click Check my progress to verify the objective.
The query you created in the previous task is helpful, but it is missing some critical information. For example, you don't know the menu item name, and there are extraneous decimal places in the total_revenue column.
To get the menu item name, you must join the menu and order_item tables. You can also format the total_revenue field so that only two decimal places are displayed.
In this task, you use the transform feature of Gemini to write prompts to address these gaps.
Click SQL query () to create a new SQL query. A new tab is displayed in BigQuery Studio.
Click SQL generation tool () to access the SQL generation tool. You see the Generate SQL with Gemini dialog. You can enter a natural language prompt in this window to generate a new SQL statement.
Enter the following prompt:
Click Generate. You see Gemini create a SQL statement similar to the following:
Click Insert. The query you generated is added to the Untitled query tab.
Select the query.
Click Gemini () next to the query.
Click Explain this query. You see the explanation displayed in the Gemini chat window with a summary similar to the following:
Review the details of the explanation.
menu_id and total_revenue fields, you also see the item_name field included between them.Answer these questions:
Click Check my progress to verify the objective.
Select the query.
Click Gemini () to access the SQL generation tool.
Click Transform. You see the Transform SQL with Gemini dialog appear.
Enter the following prompt:
Click Generate. You see the new query generated.
Click Insert. You see the new query in the Untitled query tab:
Click Run. Notice how the result is very similar. However, now the total_revenue field only has two decimal places.
What is the total revenue generated by Clouds of Coffee Delight?
Considering your data and use cases for BigQuery, how would you use the code generation feature?
Click Check my progress to verify the objective.
When you use Gemini with BigQuery, you also have the ability to review and debug code. When you have an error, you can use Gemini to suggest changes to improve your code so that there are no errors.
Your teammate created the following SQL code:
Their goal was to retrieve the top 10 small-sized items by total revenue from the coffee_on_wheels dataset, including the menu_id, item_name, and total_revenue fields.
However, with this SQL code, your teammate states they get this error:
And they are unable to resolve the issue.
Your task is to use Gemini and the coffee_on_wheels dataset to resolve issues with this SQL code that was generated by your team member.
Click SQL query () to create a new SQL query.
Enter the following query:
Click Run. You confirm that the query fails to run and you get the following error:
Open the Gemini chat window in BigQuery.
In the chat window, enter the following question:
Press SHIFT+ENTER (or SHIFT+RETURN on Mac) to create a new line in the chat window.
Select the query and copy it.
Paste it immediately after the question you asked.
Press SHIFT+ENTER (or SHIFT+RETURN on Mac) to create a new line in the chat window.
Enter the following sentence:
Click Send (). You get a response from Gemini.
Review the suggestions in the response. Based on these suggestions, you determine that the most likely cause of the issue is that the dataset name coffee_on_wheels is not specified within the INNER JOIN statement for the menu table in the query.
Within the suggestions, a refined query with a potential solution similar to the following is provided:
Copy the refined query.
Click SQL query () to open a new Untitled query tab.
Paste the refined query in the new Untitled query tab.
Click Run. The result is each of the top 10 small menu items with the item name and the total revenue.
This is very close to what your teammate wanted. However, there is one small missing piece to the refined query. Notice that the total_revenue field is formatted with extraneous decimal places. You can ask Gemini to correct this for you with the following steps.
In the chat window, enter the following prompt:
Press SHIFT+ENTER (or SHIFT+RETURN on Mac) to create a new line in the chat window.
Select the query and copy it.
Paste it immediately after this first part of the prompt.
Press SHIFT+ENTER (or SHIFT+RETURN on Mac) to create a new line in the chat window.
Add the following text to the end of the prompt:
Confirm that the prompt now looks similar to the following:
Click Send (). You see Gemini's response:
With an explanation similar to the following:
Copy the refactored code.
Click SQL query () to open a new Untitled query tab.
Paste the refactored query in the new Untitled query tab.
Click Run. The result is each of the top 10 small menu items with the item name and the total revenue.
You confirm that the results are what is desired and send the query back to your teammate. They thank you for your help.
Answer this question: What is the name of the item with the 5th most revenue? Also, how much revenue did it generate?
Considering your data and use cases, how would you use the code review and suggestion features to fix code you are struggling with?
Click Check my progress to verify the objective.
You have generated a SQL query with a natural language prompt and used code explanation to understand queries you are unfamiliar with. You have also used Gemini to help you review and debug code. You asked Gemini to help you with suggestions to improve or even fix your code. You are becoming more experienced with using Gemini in BigQuery to author queries with and without code. Now you even have experience troubleshooting queries. You are becoming more confident with BigQuery each day and can use Gemini to supplement your knowledge and skills.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated on November 06, 2026
Lab Last Tested November 04, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We can notify you via email when it becomes available
Great!
We can contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one