Skip to content

Tag: sql

Two rows in two columns

I have table: Owner Book Date John Vile Bodies by Evelyn Waugh 2009-05-20 Tom Vile Bodies by Evelyn Waugh 2009-05-22 Jim Moab is my Washpot by Stephen Fry 2009-05-26 Kate Moab is my Washpot by Stephen Fry 2009-06-02 How can I get table: Owner Book Pick_Date Gave_Back_Book_Date John Vile Bodies by Evelyn Waugh…

SQL group by return null if one is null

I have orders table that have delete marker column date_deleted which value is null or date order_number item_id date_deleted 111 aaa null 111 bbb null 111 ccc 2021-x-x I have query to select the fully deleted orders with group by order_number It give me this result order_number date_deleted 111 2021-x-x Whic…

Limit number of occurrences of value in a table oracle sql

I have oracle sql table of students, students are assigned to groups. I have to set constraint so there will be no more than 10 students in a group (ideally no more than N students in a group). Basically restrict table from having more than N rows with the same GROUP_ID value. Here is table declaration. I&#82…

Getting a Monthly Date Range

How can you make a date range in a big query? A date range starts from 29th of the month and ends with 28th of the next month. It should be like this Date | Starting Date | Ending Date 03-13-2020 | 02-29-2020 | 03-28-2021 06-30-2020 | 06-29-2020 | 07-28-2021 01-01-2021 | 12-29-2020 | 01-28-2021 11-11-2021 | 1…

Xquery Get Consecutive Distinct Values

Trying to get consecutive distinct from the following XML. Expected Result : Current Result : Code : The distinct-values get distinct from the whole set, but I would like to get distinct values only if there are consecutive. Answer We have a pure XQuery solution. SQL Output