-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwithout-observation.jsonl
More file actions
24 lines (24 loc) · 453 KB
/
without-observation.jsonl
File metadata and controls
24 lines (24 loc) · 453 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me images of Aurelia aurita"}, {"role": "assistant", "content": "SELECT TOP 10 i.url, i.id as image_id, b.concept, b.id\nFROM images i\nJOIN bounding_boxes b ON i.id = b.image_id\nWHERE b.concept = 'Aurelia aurita'\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: What is the maximum and minumum latitude and longitude of Atlantic Ocean"}, {"role": "assistant", "content": "SELECT min_latitude, min_longitude, max_latitude, max_longitude\nFrom marine_regions WHERE name = 'Atlantic Ocean'"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me images of Aurelia aurita in Monterey Bay"}, {"role": "assistant", "content": "SELECT i.urlSELECT TOP 10 i.url, i.id as image_id, b.concept, b.id, i.latitude, i.longitude\nFROM images i\nJOIN bounding_boxes b ON i.id = b.image_id\nJOIN marine_regions mr ON i.latitude BETWEEN mr.min_latitude AND mr.max_latitude AND\ni.longitude BETWEEN mr.min_longitude AND mr.max_longitude\nWHERE b.concept = 'Aurelia aurita'\n AND mr.name = 'Monterey Bay'\nFOR JSON PATH\nFROM images i\nJOIN bounding_boxes b ON i.id = b.image_id\nJOIN marine_regions mr ON i.latitude BETWEEN mr.min_latitude AND mr.max_latitude\nWHERE b.concept = 'Aurelia aurita'\n AND mr.name = 'Pacific Ocean'"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me images of species 'Aurelia aurita' in Monterey bay and depth less than 5k meters"}, {"role": "assistant", "content": "SELECT TOP 10 i.url, i.id as image_id, b.concept, b.id, i.depth_meters\nFROM images i\nJOIN bounding_boxes b ON i.id = b.image_id\nJOIN marine_regions mr ON i.latitude BETWEEN mr.min_latitude AND mr.max_latitude\nWHERE b.concept = 'Aurelia aurita'\n AND mr.name = 'Monterey bay'\n AND i.depth_meters < 5000\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Which location has the most Aurelia aurita"}, {"role": "assistant", "content": "SELECT TOP 10 r.name, COUNT(b.id) AS count\nFROM dbo.bounding_boxes b\nJOIN dbo.images i ON b.image_id = i.id\nJOIN dbo.marine_regions r ON i.latitude BETWEEN r.min_latitude AND r.max_latitude\n AND i.longitude BETWEEN r.min_longitude AND r.max_longitude\nWHERE b.concept = 'Aurelia aurita'\nGROUP BY r.name\nORDER BY count DESC"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: What species are frequently found near Aurelia aurita?"}, {"role": "assistant", "content": "SELECT b2.concept AS species, COUNT(*) AS frequency\nFROM dbo.bounding_boxes b1\nJOIN dbo.bounding_boxes b2 ON b1.image_id = b2.image_id\nWHERE b1.concept = 'Aurelia aurita' AND b2.concept <> 'Aurelia aurita'\nGROUP BY b2.concept\nORDER BY frequency DESC;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: How often are Aurelia aurita found near other species?"}, {"role": "assistant", "content": "WITH AureliaImages AS (\n SELECT DISTINCT image_id\n FROM dbo.bounding_boxes\n WHERE concept = 'Aurelia aurita'\n),\nOtherSpeciesInAureliaImages AS (\n SELECT DISTINCT bb1.image_id\n FROM dbo.bounding_boxes AS bb1\n JOIN dbo.bounding_boxes AS bb2 ON bb1.image_id = bb2.image_id\n WHERE bb1.concept = 'Aurelia aurita' AND bb2.concept != 'Aurelia aurita'\n)\nSELECT \n COUNT(*) AS 'Frequency',\n (SELECT COUNT(*) FROM AureliaImages) AS 'TotalAureliaImages'\nFROM OtherSpeciesInAureliaImages;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me an image containing both Aurelia aurita and Siphonophorae"}, {"role": "assistant", "content": "WITH ImageConcepts AS (\nSELECT TOP 1 i.id as image_id\nFROM dbo.images i\nWHERE \n EXISTS (\n SELECT 1\n FROM dbo.bounding_boxes b\n WHERE b.image_id = i.id AND b.concept = 'Aurelia aurita'\n )\n AND EXISTS (\n SELECT 1\n FROM dbo.bounding_boxes b\n WHERE b.image_id = i.id AND b.concept = 'Siphonophorae'\n )\nGROUP BY i.id)\nSELECT \n b.id,\n b.concept,\n i.url,\n i.id as image_id,\n b.x,\n b.y,\n b.width,\n b.height\nFROM \n dbo.images i\nJOIN \n dbo.bounding_boxes b ON i.id = b.image_id\nJOIN \n ImageConcepts c ON c.image_id = i.id\nWHERE \n b.concept IN ('Aurelia aurita', 'Siphonophorae')\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: What species are frequently found at 1000m depth?"}, {"role": "assistant", "content": "SELECT b.concept AS species, COUNT(*) AS frequency\nFROM dbo.bounding_boxes AS b\nJOIN dbo.images AS i ON b.image_id = i.id\nWHERE i.depth_meters = 1000\nGROUP BY b.concept\nORDER BY frequency DESC;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: How many distinct species are there at Monterey Bay?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT b.concept) as DistinctSpeciesCount\nFROM dbo.bounding_boxes b\nWHERE EXISTS (\n SELECT 1\n FROM dbo.images i\n JOIN dbo.marine_regions mr ON i.latitude BETWEEN mr.min_latitude AND mr.max_latitude\n AND i.longitude BETWEEN mr.min_longitude AND mr.max_longitude\n WHERE mr.name = 'Monterey Bay'\n AND i.id = b.image_id\n)"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me images of Aurelia aurita that looks good\n"}, {"role": "assistant", "content": "SELECT TOP 10 i.url, b.concept, b.id, i.id as image_id\nFROM dbo.bounding_boxes AS b\nJOIN dbo.images AS i ON b.image_id = i.id\nWHERE b.concept = 'Aurelia aurita'\nORDER BY (b.width * b.height) / (i.width * i.height) DESC\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Give data of all species in Monterey Bay to show in a heatmap"}, {"role": "assistant", "content": "SELECT\n b.concept,\n b.id,\n i.latitude,\n i.longitude,\n i.depth_meters\nFROM\n dbo.bounding_boxes b\n JOIN dbo.images i ON b.image_id = i.id\n JOIN dbo.marine_regions mr ON i.latitude BETWEEN mr.min_latitude AND mr.max_latitude\n AND i.longitude BETWEEN mr.min_longitude AND mr.max_longitude\nWHERE\n mr.name = 'Monterey Bay'\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me a place where Aurelia aurita is found the most"}, {"role": "assistant", "content": "SELECT TOP 1 mr.name as region_name, COUNT(bb.id) as count\nFROM dbo.bounding_boxes bb\nJOIN dbo.images i ON bb.image_id = i.id\nJOIN dbo.marine_regions mr ON i.latitude BETWEEN mr.min_latitude AND mr.max_latitude AND i.longitude BETWEEN mr.min_longitude AND mr.max_longitude\nWHERE bb.concept = 'Aurelia aurita'\nGROUP BY mr.name\nORDER BY count DESC"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Provide the data that correlates salinity levels with the distribution of Aurelia aurita"}, {"role": "assistant", "content": "WITH SalinityLevels AS (\n SELECT '<32' AS salinity_level\n UNION ALL\n SELECT '32-33'\n UNION ALL\n SELECT '33-34'\n UNION ALL\n SELECT '34-35'\n UNION ALL\n SELECT '35-36'\n UNION ALL\n SELECT '36-37'\n UNION ALL\n SELECT '>37'\n),\nAggregatedData AS (\n SELECT \n CASE \n WHEN images.salinity < 32 THEN '<32'\n WHEN images.salinity BETWEEN 32 AND 33 THEN '32-33'\n WHEN images.salinity BETWEEN 33 AND 34 THEN '33-34'\n WHEN images.salinity BETWEEN 34 AND 35 THEN '34-35'\n WHEN images.salinity BETWEEN 35 AND 36 THEN '35-36'\n WHEN images.salinity BETWEEN 36 AND 37 THEN '36-37'\n WHEN images.salinity > 37 THEN '>37'\n END AS salinity_level,\n COUNT(bounding_boxes.concept) AS species_count\n FROM \n dbo.images\n JOIN \n dbo.bounding_boxes ON images.id = bounding_boxes.image_id\n WHERE \n bounding_boxes.concept = 'Aurelia aurita'\n AND \n images.salinity IS NOT NULL\n GROUP BY \n CASE \n WHEN images.salinity < 32 THEN '<32'\n WHEN images.salinity BETWEEN 32 AND 33 THEN '32-33'\n WHEN images.salinity BETWEEN 33 AND 34 THEN '33-34'\n WHEN images.salinity BETWEEN 34 AND 35 THEN '34-35'\n WHEN images.salinity BETWEEN 35 AND 36 THEN '35-36'\n WHEN images.salinity BETWEEN 36 AND 37 THEN '36-37'\n WHEN images.salinity > 37 THEN '>37'\n END\n)\nSELECT \n sl.salinity_level,\n COALESCE(ad.species_count, 0) AS species_count\nFROM \n SalinityLevels sl\nLEFT JOIN \n AggregatedData ad ON sl.salinity_level = ad.salinity_level\nORDER BY \n salinity_level;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Provide the data that correlates depth with the distribution of Aurelia aurita\n"}, {"role": "assistant", "content": "WITH DepthLevels AS (\n SELECT 'Epipelagic (0-200m)' AS depth_level, 0 AS min_depth, 200 AS max_depth\n UNION ALL\n SELECT 'Mesopelagic (200-1000m)', 200, 1000\n UNION ALL\n SELECT 'Bathypelagic (1000-4000m)', 1000, 4000\n UNION ALL\n SELECT 'Abyssopelagic (4000-6000m)', 4000, 6000\n UNION ALL\n SELECT 'Hadalpelagic (>6000m)', 6001, 1000000 -- assuming a large max value to capture everything > 6000\n),\nAggregatedData AS (\n SELECT \n CASE \n WHEN images.depth_meters BETWEEN 0 AND 200 THEN 'Epipelagic (0-200m)'\n WHEN images.depth_meters BETWEEN 200 AND 1000 THEN 'Mesopelagic (200-1000m)'\n WHEN images.depth_meters BETWEEN 1000 AND 4000 THEN 'Bathypelagic (1000-4000m)'\n WHEN images.depth_meters BETWEEN 4000 AND 6000 THEN 'Abyssopelagic (4000-6000m)'\n WHEN images.depth_meters > 6000 THEN 'Hadalpelagic (>6000m)'\n END AS depth_level,\n COUNT(bounding_boxes.id) AS distribution\n FROM \n images \n JOIN \n bounding_boxes \n ON \n images.id = bounding_boxes.image_id\n WHERE \n bounding_boxes.concept = 'Aurelia aurita'\n AND \n images.depth_meters IS NOT NULL\n GROUP BY \n CASE \n WHEN images.depth_meters BETWEEN 0 AND 200 THEN 'Epipelagic (0-200m)'\n WHEN images.depth_meters BETWEEN 200 AND 1000 THEN 'Mesopelagic (200-1000m)'\n WHEN images.depth_meters BETWEEN 1000 AND 4000 THEN 'Bathypelagic (1000-4000m)'\n WHEN images.depth_meters BETWEEN 4000 AND 6000 THEN 'Abyssopelagic (4000-6000m)'\n WHEN images.depth_meters > 6000 THEN 'Hadalpelagic (>6000m)'\n END\n)\nSELECT \n dl.depth_level, \n COALESCE(ad.distribution, 0) AS distribution\nFROM \n DepthLevels dl\nLEFT JOIN \n AggregatedData ad ON dl.depth_level = ad.depth_level\nORDER BY \n dl.min_depth;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find place that has the highest temperature and species that is found the most at that place\n"}, {"role": "assistant", "content": "WITH RegionAvgTemp AS (\n SELECT \n r.name as region_name,\n AVG(i.temperature_celsius) as avg_temperature\n FROM dbo.images i\n JOIN dbo.marine_regions r ON \n i.latitude BETWEEN r.min_latitude AND r.max_latitude AND\n i.longitude BETWEEN r.min_longitude AND r.max_longitude\n GROUP BY r.name\n),\nMaxTempRegion AS (\n SELECT TOP 1 region_name, avg_temperature\n FROM RegionAvgTemp\n ORDER BY avg_temperature ASC\n),\nMostFoundSpecies AS (\n SELECT \n b.concept, \n COUNT(*) as count\n FROM dbo.bounding_boxes b\n JOIN dbo.images i ON b.image_id = i.id\n JOIN dbo.marine_regions r ON \n i.latitude BETWEEN r.min_latitude AND r.max_latitude AND\n i.longitude BETWEEN r.min_longitude AND r.max_longitude\n JOIN MaxTempRegion m ON r.name = m.region_name\n GROUP BY b.concept\n)\nSELECT TOP 1 bb.id, mfs.concept, mfs.count, mtr.avg_temperature, mtr.region_name\nFROM MostFoundSpecies mfs\nJOIN dbo.bounding_boxes bb ON bb.concept = mfs.concept\nJOIN MaxTempRegion mtr ON 1=1\nORDER BY mfs.count ASC\nFOR JSON PATH;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find the species that are found in image with id 2256720\n"}, {"role": "assistant", "content": "SELECT b.concept, b.id, i.id as image_id, i.url as url\nFROM dbo.bounding_boxes AS b\nJOIN dbo.images AS i ON b.image_id = i.id\nWHERE b.image_id = 2256720\nFOR JSON PATH;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find the species that is found in bounding box table with id 2258719"}, {"role": "assistant", "content": "SELECT concept, id\nFROM dbo.bounding_boxes \nWHERE id = 2258719\nFOR JSON PATH;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Identify the two species that most frequently appear together within a single image"}, {"role": "assistant", "content": "SELECT TOP 1\n bb1.concept AS species1, \n bb2.concept AS species2, \n COUNT(*) AS frequency\nFROM \n dbo.bounding_boxes AS bb1\nJOIN \n dbo.bounding_boxes AS bb2 \nON \n bb1.image_id = bb2.image_id AND bb1.concept < bb2.concept\nGROUP BY \n bb1.concept, \n bb2.concept"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Provide an image showcasing the highest concentration of Bathochordaeus stygius"}, {"role": "assistant", "content": "WITH HighestConcentrationImage AS (\n SELECT TOP 1\n i.id as image_id,\n COUNT(b.id) as concentration\n FROM\n dbo.images i\n JOIN\n dbo.bounding_boxes b ON i.id = b.image_id\n WHERE\n b.concept = 'Bathochordaeus stygius' OR b.alt_concept = 'Bathochordaeus stygius'\n GROUP BY\n i.id\n ORDER BY\n concentration DESC\n)\nSELECT \n b.id,\n b.concept,\n i.url,\n i.id as image_id,\n b.x,\n b.y,\n b.width,\n b.height\nFROM \n dbo.images i\nJOIN \n dbo.bounding_boxes b ON i.id = b.image_id\nJOIN \n HighestConcentrationImage hci ON hci.image_id = i.id\nWHERE \n b.concept = 'Bathochordaeus stygius'\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: In what pressure level is the species with bounding box id 2258729 living at"}, {"role": "assistant", "content": "\nSELECT images.pressure_dbar\nFROM dbo.bounding_boxes\nJOIN dbo.images ON bounding_boxes.image_id = images.id\nWHERE bounding_boxes.id = 2258739;"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Provide me few images of Asterias rubens, Acanthaster planci, Linckia laevigata, Protoreaster nodosus, Pycnopodia helianthoides\n"}, {"role": "assistant", "content": "SELECT TOP 5\n i.url AS url,\n b.concept AS concept,\n b.id as id,\n b.image_id as image_id\nFROM \n dbo.bounding_boxes AS b\nJOIN \n dbo.images AS i ON b.image_id = i.id\nWHERE \n b.concept IN ('Asterias rubens', 'Acanthaster planci', 'Linckia laevigata', 'Protoreaster nodosus', 'Pycnopodia helianthoides')\nFOR JSON PATH"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: How many images of Pycnopodia helianthoides are in the database\n"}, {"role": "assistant", "content": "SELECT COUNT(*) as TotalImages\nFROM dbo.bounding_boxes \nWHERE concept = 'Pycnopodia helianthoides';"}]}
{"messages": [{"role": "system", "content": "You are a text-to-sql generator. You have a database of marine species. You must provide the response only in sql format. The sql should be generated in a way such that the response from sql is also in the expected format"}, {"role": "user", "content": "\n The database has the following structure.\n\n CREATE TABLE \"dbo\".\"bounding_box_comments\" (\n \"id\" \tbigint NOT NULL,\n \"bounding_box_uuid\" \tuniqueidentifier NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"text\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"alternate_concept\" \tvarchar(255) NULL,\n \"flagged\" \tbit NULL,\n CONSTRAINT \"PK__bounding__3213E83F71625CCD\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes\" (\n \"id\" \tbigint NOT NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__3213E83F3E4C2D08\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"bounding_boxes_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"concept\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"group_of\" \tbit NULL,\n \"height\" \tint NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"observer\" \tvarchar(256) NULL,\n \"occluded\" \tbit NULL,\n \"truncated\" \tbit NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"verification_timestamp\"\tdatetimeoffset(6) NULL,\n \"verified\" \tbit NULL,\n \"verifier\" \tvarchar(256) NULL,\n \"width\" \tint NULL,\n \"x\" \tint NULL,\n \"y\" \tint NULL,\n \"image_id\" \tbigint NULL,\n \"alt_concept\" \tvarchar(255) NULL,\n \"user_defined_key\" \tvarchar(56) NULL,\n CONSTRAINT \"PK__bounding__BE3894F99D30F28A\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"darwin_cores\" (\n \"id\" \tbigint NOT NULL,\n \"access_rights\" \tvarchar(1024) NULL,\n \"basis_of_record\" \tvarchar(64) NULL,\n \"bibliographic_citation\"\tvarchar(512) NULL,\n \"collection_code\" \tvarchar(64) NULL,\n \"collection_id\" \tvarchar(2048) NULL,\n \"data_generalizations\" \tvarchar(512) NULL,\n \"dataset_id\" \tuniqueidentifier NULL,\n \"dataset_name\" \tvarchar(255) NULL,\n \"dynamic_properties\" \tvarchar(2048) NULL,\n \"information_withheld\" \tvarchar(255) NULL,\n \"institution_code\" \tvarchar(255) NULL,\n \"institution_id\" \tvarchar(255) NULL,\n \"license\" \tvarchar(2048) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"owner_institution_code\"\tvarchar(255) NULL,\n \"record_language\" \tvarchar(35) NULL,\n \"record_references\" \tvarchar(2048) NULL,\n \"record_type\" \tvarchar(32) NULL,\n \"rights_holder\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"image_set_upload_id\" \tbigint NULL,\n CONSTRAINT \"PK__darwin_c__3213E83F92DAE497\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities\" (\n \"id\" \tbigint NOT NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(255) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(255) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__3213E83F59FE1468\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"fathomnet_identities_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"api_key\" \tvarchar(255) NULL,\n \"avatar_url\" \tvarchar(2000) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"disabled\" \tbit NULL,\n \"display_name\" \tvarchar(255) NULL,\n \"email\" \tvarchar(254) NULL,\n \"expertise_rank\" \tvarchar(32) NULL,\n \"firebase_uid\" \tvarchar(64) NULL,\n \"job_title\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"orcid\" \tvarchar(32) NULL,\n \"organization\" \tvarchar(255) NULL,\n \"profile\" \tvarchar(1024) NULL,\n \"role_data\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"notification_frequency\"\tvarchar(32) NULL,\n CONSTRAINT \"PK__fathomne__BE3894F9CD98EF78\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"followed_topics\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"email\" \tvarchar(254) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"notification\" \tbit NULL,\n \"target\" \tvarchar(256) NULL,\n \"topic\" \tvarchar(32) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n CONSTRAINT \"PK__followed__3213E83F4A1EA9E0\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_set_uploads\" (\n \"id\" \tbigint NOT NULL,\n \"contributors_email\" \tvarchar(255) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"format\" \tvarchar(255) NULL,\n \"last_updated_timestamp\" \tdatetime2(6) NULL,\n \"local_path\" \tvarchar(2048) NULL,\n \"rejection_details\" \tvarchar(255) NULL,\n \"rejection_reason\" \tvarchar(255) NULL,\n \"remote_uri\" \tvarchar(2048) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"status\" \tvarchar(255) NULL,\n \"status_update_timestamp\"\tdatetimeoffset(6) NULL,\n \"status_updater_email\" \tvarchar(254) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"darwincore_id\" \tbigint NULL,\n CONSTRAINT \"PK__image_se__3213E83F9C72A0E9\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"image_uploads_join\" (\n \"imagesetupload_id\"\tbigint NOT NULL,\n \"image_id\" \tbigint NOT NULL,\n CONSTRAINT \"PK__image_up__8A53EE0EBD9D776A\" PRIMARY KEY CLUSTERED(\"imagesetupload_id\",\"image_id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"submitter\" \tvarchar(255) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(2048) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images__3213E83FD76E309F\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"images_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"contributors_email\" \tvarchar(254) NULL,\n \"created_timestamp\" \tdatetime2(6) NULL,\n \"depth_meters\" \tfloat NULL,\n \"height\" \tint NULL,\n \"imaging_type\" \tvarchar(64) NULL,\n \"last_updated_timestamp\"\tdatetime2(6) NULL,\n \"last_validation\" \tdatetimeoffset(6) NULL,\n \"latitude\" \tfloat NULL,\n \"longitude\" \tfloat NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"modified\" \tdatetimeoffset(6) NULL,\n \"sha256\" \tvarchar(64) NULL,\n \"timestamp\" \tdatetimeoffset(6) NULL,\n \"url\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"valid\" \tbit NULL,\n \"width\" \tint NULL,\n \"altitude\" \tfloat NULL,\n \"oxygen_ml_l\" \tfloat NULL,\n \"pressure_dbar\" \tfloat NULL,\n \"salinity\" \tfloat NULL,\n \"temperature_celsius\" \tfloat NULL,\n CONSTRAINT \"PK__images_a__BE3894F92DF6715C\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"marine_regions\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"max_latitude\" \tfloat NOT NULL,\n \"max_longitude\" \tfloat NOT NULL,\n \"min_latitude\" \tfloat NOT NULL,\n \"min_longitude\" \tfloat NOT NULL,\n \"mrgid\" \tbigint NULL,\n \"name\" \tvarchar(255) NULL,\n CONSTRAINT \"PK__marine_r__3213E83FE987FC8B\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"revinfo\" (\n \"rev\" \tint IDENTITY(1,1) NOT NULL,\n \"revtstmp\"\tbigint NULL,\n CONSTRAINT \"PK__revinfo__C2B7CC69D3938648\" PRIMARY KEY CLUSTERED(\"rev\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags\" (\n \"id\" \tbigint NOT NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NOT NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NOT NULL,\n \"value\" \tvarchar(255) NOT NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags__3213E83F3A490684\" PRIMARY KEY CLUSTERED(\"id\")\n ON [PRIMARY]);\n CREATE TABLE \"dbo\".\"tags_aud\" (\n \"id\" \tbigint NOT NULL,\n \"rev\" \tint NOT NULL,\n \"revtype\" \tsmallint NULL,\n \"created_timestamp\" \tdatetime2 NULL,\n \"tag\" \tvarchar(255) NULL,\n \"last_updated_timestamp\"\tdatetime2 NULL,\n \"media_type\" \tvarchar(255) NULL,\n \"uuid\" \tuniqueidentifier NULL,\n \"value\" \tvarchar(255) NULL,\n \"image_id\" \tbigint NULL,\n CONSTRAINT \"PK__tags_aud__BE3894F94F1608A8\" PRIMARY KEY CLUSTERED(\"id\",\"rev\")\n ON [PRIMARY]);\n CREATE VIEW \"dbo\".\"boundingbox_extended_info\" AS\n SELECT\n b.concept,\n b.alt_concept,\n b.observer,\n b.verified,\n b.verifier,\n b.verification_timestamp,\n b.user_defined_key,\n i.url,\n i.width,\n i.height,\n i.submitter,\n i.[timestamp],\n i.contributors_email AS image_contributors_email,\n u.contributors_email AS upload_contributors_email,\n dc.owner_institution_code,\n dc.institution_code,\n dc.rights_holder,\n dc.collection_code,\n dc.collection_id,\n dc.dataset_name\n FROM\n dbo.darwin_cores dc LEFT JOIN\n dbo.image_set_uploads u ON dc.id = u.darwincore_id LEFT JOIN\n dbo.image_uploads_join j ON j.imagesetupload_id = u.id LEFT JOIN\n dbo.images i ON j.image_id = i.id LEFT JOIN\n dbo.bounding_boxes b ON b.image_id = i.id\n ;\n\n If the prompt is asking about species or images of individual species, draft the sql in such a way that it generates json array containing the species data. Species data must contain species concept and bounding box id as id.\n\n Prompt: Find me some images that has Acanthaster planci, Chrysaora fuscescens and Siphonophorae\n"}, {"role": "assistant", "content": "WITH ImageConcepts AS (\n SELECT TOP 5 i.id as image_id\n FROM dbo.images i\n JOIN dbo.bounding_boxes b ON i.id = b.image_id\n WHERE b.concept IN ('Aurelia aurita', 'Chrysaora fuscescens', 'Siphonophorae')\n GROUP BY i.id\n HAVING COUNT(DISTINCT b.concept) = 3\n)\nSELECT \n b.id,\n b.concept,\n i.url,\n i.id as image_id,\n b.x,\n b.y,\n b.width,\n b.height\nFROM \n dbo.images i\nJOIN \n dbo.bounding_boxes b ON i.id = b.image_id\nJOIN \n ImageConcepts c ON c.image_id = i.id\nWHERE \n b.concept IN ('Aurelia aurita', 'Chrysaora fuscescens', 'Siphonophorae')\nFOR JSON PATH"}]}