Skip to content

Tag: sql

Appending Name based on Min and Max datetime

I have Event_No, Events, Date Range in my table like below. I need to show Min datetime respective Event name with ‘IN'(a concatenation of (Event-‘IN’))and Max datetime respective Event with Out(a concatenation of (Event-‘Out’)). I need My Final Output like below Thanks Answer Th…

SQL: how to select distinct values with an offset

Given the following table: id value ——- ——- 0 1 1 6 2 7 3 9 4 2 5 20 6 21 7 3 I’m wondering if there’s a way to select distinct rows where there’s a difference between (integer) values of (for example) 3, giving a priority to id (low id value = more prioririty). Progr…

Sybase ASE: how to print all table rows using cursor?

The following code is supposed to print all rows contained in the temporary table #table_A: However, it results in the following error message: How can I print all rows contained in a (temporary) table? Here’s another way of putting my question: I’m trying to do something like that: Is there a way…