-1

I am trying to get data with a query in Google Sheets:

I have the following dataset :

Name Date Status
John 2025-04-16 Done
John 2025-04-17 Done
John 2025-04-18 Incomplete
James 2025-04-16 Incomplete
James 2025-04-17 Done
James 2025-04-18 Incomplete
Lisa 2025-04-16 Done
Lisa 2025-04-17 Done
Lisa 2025-04-18 Done

Is it possible in SQL query to get the following

Name 2025-04-16 2025-04-17 2025-04-18
John Done Done Incomplete
James Incomplete Done Incomplete
Lisa Done Done Done

I am struggling to get the right query, if it even possible

I tried with pivot tables but did not get the status in the columns

New contributor
Jaco Annandale is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
5
  • 2
    Yes, it's possible, please take a look at any of the almost 25000 questions about that subject, see: stackoverflow.com/search?q=sql+pivot, and tell us where you are lost. Also include the needed information that is under the tag sql ("Questions should include code examples, table structure, sample data, and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used")
    – Luuk
    Commented Apr 21 at 13:50
  • Be aware: SQL has a strict rule that you have to know about the columns you're quering before looking at ANY data in the table. If the columns depend on the data, you have to do this over a few steps: 1) query the table to find out what columns you'll need. 2) use results from step 1 to build a new query on the fly with those columns. 3) run the query from step 2. Commented Apr 21 at 13:52
  • "I tried with pivot tables but did not get the status in the columns" Show us what you tried. (Please use edit to add that info to the question!)
    – Luuk
    Commented Apr 21 at 13:52
  • Wow what a quick response. I forgot to add that this is is in a query for google sheets Commented Apr 21 at 13:57
  • 1
    @JacoAnnandale What do you mean by "a query for Google Sheets"? If this about the QUERY function for Google Sheets formulas, you should use the google-query-language tag instead of sql
    – Wicket
    Commented Apr 21 at 14:28

1 Answer 1

2

Here's one approach you may test out:

=query(A2:C,"Select A,max(C) Where A!='' group by A pivot B",0)

enter image description here

1
  • Thanks, that is exactly what I wanted. Was difficult to explain in words. You nailed it Commented Apr 23 at 8:34

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.