I am looking to find the sum of the current + the last X Nth Rows. I am able to do this with the following query, however it is not very scalable. If this example, I’m finding the current value of “amount”, plus the last 3 “amounts” split 6 apart: X = 3 N = 6 I will be using
Tag: nested-queries
How can I override rows from another table?
I have two tables: TableA ID Name — —- 1 aaa 2 bbb 3 ccc 4 ddd TableB ID Name — ——– 3 WWXXYYZZ I want to select from both tables, but skip the rows which exist in TableB. The …
How to exclude certain values from a Query [SQL]
as the title states, an NotPrimID, can have two different values Example 1 and Example 2 IF: if NotPrimID does have both values, it should be automatically excluded from the query result. What i want: Query, that will deliever all the NotPrimID, that only have “Example 1” as a result, however if NotPrimID does have “Example 2” also as a
How to find distinct columns in a nested subquery in SQL?
I need to find the distinct drinkers that ordered ‘VODKA’ and ‘WHISKY’. I AM ONLY ALLOWED TO USE A NESTED QUERY. No other format is accepted. I am quite new to sql so any help would be greatly appreciated! Here are the tables I am trying to retrieve data from: Here is my SELECT statement so far: INSERT STATEMENTS: DESIRED