SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


First and Last data


First and Last data

Author
Message
Nita Reddy
Nita Reddy
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1089 Visits: 411
from the below table I need the Last_data and last_data from 6 month. with different DB_name
so my output would look like :
DB_name backup_start Backup_finish
Stock_any 8/1/2016 8/1/2016
Stock_any 1/1/2017 1/1/2017
Bond 8/1/2016 8/1/2016
Bond 1/1/2017 1/1/2017

DB name backup Start Backup Finish
Stock_Any 5/1/2016 5/1/2016
Stock_Any 6/1/2016 6/1/2016
Stock_Any 7/1/2016 7/1/2016
Stock_Any 8/1/2016 8/1/2016
Stock_Any 9/1/2016 9/1/2016
Stock_Any 10/1/2016 10/1/2016
Stock_Any 11/1/2016 11/1/2016
Stock_Any 12/1/2016 12/1/2016
Stock_Any 1/1/2017 1/1/2017
bond 5/1/2016 5/1/2016
bond 6/1/2016 6/1/2016
bond 7/1/2016 7/1/2016
bond 8/1/2016 8/1/2016
bond 9/1/2016 9/1/2016
bond 10/1/2016 10/1/2016
bond 11/1/2016 11/1/2016
bond 12/1/2016 12/1/2016
bond 1/1/2017 1/1/2017
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (53K reputation)SSC Guru (53K reputation)SSC Guru (53K reputation)SSC Guru (53K reputation)SSC Guru (53K reputation)SSC Guru (53K reputation)SSC Guru (53K reputation)SSC Guru (53K reputation)

Group: General Forum Members
Points: 53486 Visits: 21207
Nita Reddy (1/11/2017)
from the below table I need the Last_data and last_data from 6 month. with different DB_name
so my output would look like :
DB_name backup_start Backup_finish
Stock_any 8/1/2016 8/1/2016
Stock_any 1/1/2017 1/1/2017
Bond 8/1/2016 8/1/2016
Bond 1/1/2017 1/1/2017

DB name backup Start Backup Finish
Stock_Any 5/1/2016 5/1/2016
Stock_Any 6/1/2016 6/1/2016
Stock_Any 7/1/2016 7/1/2016
Stock_Any 8/1/2016 8/1/2016
Stock_Any 9/1/2016 9/1/2016
Stock_Any 10/1/2016 10/1/2016
Stock_Any 11/1/2016 11/1/2016
Stock_Any 12/1/2016 12/1/2016
Stock_Any 1/1/2017 1/1/2017
bond 5/1/2016 5/1/2016
bond 6/1/2016 6/1/2016
bond 7/1/2016 7/1/2016
bond 8/1/2016 8/1/2016
bond 9/1/2016 9/1/2016
bond 10/1/2016 10/1/2016
bond 11/1/2016 11/1/2016
bond 12/1/2016 12/1/2016
bond 1/1/2017 1/1/2017


Please present your data in consumable format – you've been here long enough to know how to do this.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43192 Visits: 19859
What have you tried?
How do you define Last_data and last_data from 6 month?
Are the backup Start and Backup Finish dates always the same? Do they include times?


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
sgmunson
sgmunson
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17861 Visits: 4647
Nita Reddy - Wednesday, January 11, 2017 11:32 AM
from the below table I need the Last_data and last_data from 6 month. with different DB_nameso my output would look like BigGrinB_name backup_start Backup_finishStock_any 8/1/2016 8/1/2016Stock_any 1/1/2017 1/1/2017Bond 8/1/2016 8/1/2016Bond 1/1/2017 1/1/2017DB name backup Start Backup FinishStock_Any 5/1/2016 5/1/2016Stock_Any 6/1/2016 6/1/2016Stock_Any 7/1/2016 7/1/2016Stock_Any 8/1/2016 8/1/2016Stock_Any 9/1/2016 9/1/2016Stock_Any 10/1/2016 10/1/2016Stock_Any 11/1/2016 11/1/2016Stock_Any 12/1/2016 12/1/2016Stock_Any 1/1/2017 1/1/2017bond 5/1/2016 5/1/2016bond 6/1/2016 6/1/2016bond 7/1/2016 7/1/2016bond 8/1/2016 8/1/2016bond 9/1/2016 9/1/2016bond 10/1/2016 10/1/2016bond 11/1/2016 11/1/2016bond 12/1/2016 12/1/2016bond 1/1/2017 1/1/2017

You mention "from 6 month", but your sample output includes August 1st and January 1st, which are exactly 5 months apart, not six. Please explain that discrepancy as well as provide your data in consumable form, which means CREATE TABLE statements and INSERT statements.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search