I tried top % but that is not working in Oracle SQL. Offset and fetch next are working but I am not able to give percentage. What will be the best way to fetch middle 80% rows? Any help will be appreciated, thanks! Answer Middle 80%? That’s between 10 and 90%, then? Let’s suppose it is. Sample dat…
Tag: sql
Query to Return Records with Consecutive Dates by Group in Access 2016
I have a table with a date and an ID field. An extract is set out below. I would like to run a query to return all records where the same ID appears on consecutive dates. There may be no consecutive dates or two or more consecutive dates. Here is the extract: Date No_ID 09/06/2021 24694000 09/06/2021 20102886…
How to set up sqlite to be local server (on lan)
Current situation : I have one GUI program(written by python) which using sqlite data stored on my computer. Wishlist: I would like to have one server computer to locate sqlite data (DATA A1) (CRUD operation needed) and ten more client computer using GUI program(written by python) which connect with the sqlit…
How to split string with delimiter and get the first value
I have the following query where I have a table which is storing from information with a delimiter SQL version – Microsoft SQL Azure (RTM) – 12.0.2000.8 Getting the following results Where I need the results to be Answer If you only interested in the first value, you don’t need to use STRING…
How to add a query to a table in SQL?
I have 3 tables. For simplicity I changed them to these sample tables. table1: CorporateActionSmmary table2# ProductMaster table3# OpenPosition First I need to add ISIN from table2 to table1 table1: CorporateActionSmmary So, I used this code Now as you can see the Quantity is missing in Table1 so I have to ad…
Filter rows of a table based on a condition that implies: 1) value of a field within a range 2) id of the business and 3) date?
I want to filter a TableA, taking into account only those rows whose “TotalInvoice” field is within the minimum and maximum values expressed in a ViewB, based on month and year values and RepairShopId (the sample data only has one RepairShopId, but all the data has multiple IDs). In the view I hav…
How to avoid rerunning a subquery used multiple times?
The following is a simplified example of a problem I’m running into. Assume I have a query “SomeQuery” (SELECT… FROM… WHERE…) that gives an output that looks like this: Status MyDate A 6/14/2021 A 6/12/2021 B 6/10/2021 A 6/8/2021 B 6/6/2021 A 6/4/2021 I need to get the earl…
MS Access query requires a Parameter to be enter by the user if I have combined custom columns and have a criteria in that column
In the following query everything works well But if I want to add a criteria to column gtotal Access will ask for parameter values for copy1, copy2, and copy3. Why does the search criteria trigger the parameter requests? I get no request without the criteria and total shows the expected values. Answer Prompts…
How to select records from January 1, 2021 to last week
I was wondering how to make a query where I can select data from Jan 1, 21 to last week. I tried to put it in the date filter like this: but I would have to manually go in every week to change the end date, I was wondering if there is a more efficient way to select for data
For each product get the second customer who made a purchase
Given a table: Question: For each product get the second customer who made a purchase The following query Gives the result: And the expect result is: Here is the script to create a table: Answer You need to pair down the customers first so there is only one record per customer: