You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sandesh Kota edited this page Nov 22, 2019
·
2 revisions
How to get the difference between two numbers from different rows in SQL (the max range in the column)
ID Amount
101 10000
101 5000
101 3000
The result should be
ID Amount
101 7000
Tip: Difference using Max & Min
How to get the date difference of last two max dates
Date
20-8-2019
25-8-2019
10-8-2019
29-8-2019
The result should be : 4 days -Difference between 29-8-2019 & 25-8-2019, which are the last two max days
Diff
4
Tip: Select max 2 and then difference using Max & Min
How do I keep adding data to a variable from a table
Name
Sandesh
Ramesh
Suresh
The result should be
Name
Sandesh, Ramesh, Suresh
Tip: COALESCE
4 Output ?
- Select 1a
- Select a =15
- select number from (values (1, 3), (2, 4)) as X(number, dummy)
- SELECT * FROM (values (1),(2),(null)) as c(id) where c.Id in (1,3, null)
- SELECT * FROM (values (1),(2),(null)) as c(id) where c.Id not in (1,3, null)