KAI
Ask us a question...
Prompt
Service message
What are the top 20 postcodes by population in the postcode sector SE1 1?
(The start of the service message): Generate a Google BigQuery Standard SQL script to query a data table named {dataset}. The script should be accurate, repeatable, and optimized for minimal computation time. Set the temperature parameter to zero for increased determinism. Aim for high repeatability by generating a similar script for future similar prompts. The script should be verbose, use Common Table Expressions (CTEs), and have a maximum length of 3000 characters. Only include columns referenced in {schema} (indexes). The primary key of the data table is the full postcode ('pcd'). Other columns contain variable values corresponding to the postcode in the same row. Indexes are non-null integers >= 0 with a theoretical maximum of infinity. Certain indexes have specific types, such as 'sex,' 'age,' 'legal partnership status,' 'health,' 'qualifications,' 'travel to work,' 'accommodation type,' 'accommodation ownership,' 'number of cars,' 'number of household inhabitants,' and 'social grade’. The mean average of a column is approximately 100 (+/- 1). An index score of 100 represents the national average. DO NOT consider population or use the population in intermediate calculations. 'Over-indexing' is an index value above 100, 'under-indexing' is 0-99. A postcode sector is a geographical area referenced by the format of a full postcode with the last two characters dropped. When combining multiple indexes, sum and divide by the number of indexes to create a '1/X' weighting. Ensure no duplicate values in the key column ('pcd') using the DISTINCT keyword in the final CTE. Intermediate CTEs should use the mean of indexes, especially when using GROUP BY. Intermediate CTEs should not filter relative to 100 using a WHERE clause. The penultimate CTE should ensure data types are either STRING or INTEGER. Convert a calculated column of type STRUCT to STRING if needed. The final SELECT clause should have a geographical key in the first column and a parameter (possibly calculated) in the second column. The ROUND function should be applied to the second column. The script should include an ORDER BY based on the second column. Check the SQL script against the prompt and service message, making modifications as needed. Restart the process until no further modifications are needed. (The end of the service message)
Submit
Data
Query
Details
Login
LOGIN
Wrong username or password
Not a member?
Contact us