Lets say we have Passengers, where Passengers can attend many Flights, and one Flight may have many Passengers. In each Flight, each Passenger has a unique selection of Movies he/she can watch. For Passengers, Flights, and the association between them, we have three tables: For Movies, it must specify for which Passenger and for which Flight will it be available
How to make RANK() or ROW_NUMBER() in ingres/vectorwise ? issue sql code
I am writing a sql query to get sales for different stores on a given day. The query is run against ingres/vectorwise. I want to add a column rank where there is the ranking of the store in regard of …
ORACLE SQL: Group the data by the last 4 weeks
i have a trouble with dates, i need to do a query that count the ids from the last four weeks. I tried this, but it doesn’t works. SELECT count(a.id), sysdate FROM table_1 a, table_2 b WHERE b.fk_id …
Sql two multique unique ignore when first case ocours
My table has four columns city, zipcode, number and extra. I created unique group for city, zipcode and number called unique1 and another group for city,zipcode,number and extra called unique2. Those …
Is there a more efficient way of returning records that match the max value?
I have a table with fields of interest: Order Shift DateTime 23605624 Red 43470.23958 23605624 Yellow 43469.73958 23605624 Green 43469.38542 23605917 Red 43471.26042 …
Make Entire Result set into a Single Row
i have to convert the entire result in Oracle into a single row result set with different column names I have tried with some self joins but not appears to be working . Expected output
Aggregate Functions And GROUP BY
I have following query as homework for sql:- Write a query that tells how many books each author has written. On each row provide first the authorid, followed by the number of books. Order the …
How To Use Latest Date As A Condition In Query
I have a few table, and one of it is “peminjaman” which have “date” atribute type in it, which is “tarikhpemulangan” example=”2019-07-23″ . I want to select from “peminjaman” where the atribute “…
Return only distinct values from multiple SQL correlated sub-queries
This query partially completes. It returns 16 of 1,135 rows. The error message below indicates duplicates in the sub-queries. I have tried inserting DISTINCT and IN syntax to no avail. Any help would …
Unpredictable behaviour in nested CASE statement
I’m unable to figure out why the control goes always to a statement irrespective of inside CASE condition. A normal SQL statement works, but with my table it does not work. –Not working– SELECT …