Scenario: Person A takes test B three times in the span of two year. There will be three entries for that person. However, I need to write a query that tells me the number of Persons that have taken a test(just one, the latest test). The problem with this is I have a column labeled, Test_Month (xx) and Test_y…
Tag: sql
Calculate distance and only get one result for every trail_part_id
What I want to achieve is to get only the closest result for every trail_part_id. However I am stuck, I tried to use GROUP BY trail_part_id, but that did not work either as I got the following error message: SELECT list is not in GROUP BY clause and contains nonaggregated column ‘p.latpoint’ which…
How do I extract these SQL queries from these pandas dataframes?
SQL QUERIES Using SQL or Pandas, please tell me how to 1. Compare the monthly sales (GMV) trend in Q4 2019, across all countries (venture_code) 2. Show the top 10 brands for each product category, based on total sales (GMV) I wrote but got the query wrong! Answer Concerning the error, you have a space in the …
Access/SQL: How can I check if in a table all duplicates (same date) have a value of 0 except one?
I have a table in Access (tblExample) which consists of the fields ID, tripID, day and value. This table is edited by a form. When the user closes the form Access should validate the entries made. It is ok to have multiple records of the same date in day. BUT…if there are multiple records of the same da…
For all entries in one table, add to another table
Database looks like this: table1 table2 I want to make a query that passes the same data for all ID’s into table2. So after the query the database would look like the following: table1 table2 I’ve tried to make some INNER JOIN queries, but I can’t seem to make it work. Any suggestions? Answe…
Getting bounds in result with width_bucket
I’m trying to do a query using width_bucket and having a column in the results with the bounds of my buckets. Is there a simple way to do this? My query: Result: What I’m trying to get: Answer As you have a fixed sets of buckets, another option is to join against a list of ranges:
Get array size in oracle sql
I have a table in oracle with this definition Document is stored in a json format. How can i extract size for array parameters in sql? I need extract array size for each table record, and after sum all this values. ex: 1 step: 2 step: Can someone please give me an idea how to do that ? Answer Provided
Suggest SQL query for given use case
Original Table Expected Table I want all the distinct ids who have status as F but time should be maximum, if for any id status is T for given maximum time then that id should not be picked. Also only those ids should be picked who have at-least one T. For e.g 4 will not be picked at it doesn’t
how to disallow custom lists to have elements from different base lists
I have the following model: BASE_LIST: in this table we store base lists. Base list can be for example the list of cities in a continent, types of automobiles in a shop etc. ELEMENT: in this table we store the elements of base lists. For example the cities and the car types are here (Budapest, London, Paris, …
Compare the values in the successive rows and display newly added or deleted items in a different columns
I have a database with date and list of items. The problem this I do have an event date captured whenever an item is added or deleted. So what I am trying to do is comparing the items for a user ‘A’ on different days (successive rows); here the newly added or deleted items for user ‘A’…