SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Adding a date coloumn
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cocofuc25
Starting Member

Indonesia
14 Posts

Posted - 05/02/2014 :  12:07:23  Show Profile  Reply with Quote
hi guys

i have a query like following

SET NOCOUNT OFF
SET ROWCOUNT 0

DECLARE @StartDate DateTime
DECLARE @EndDate DateTime

SET @StartDate = CAST (DATEDIFF(d, 0, DATEADD(d, 1 - day(getdate()), getdate()))as datetime)
SET @EndDate = GetDate()

SELECT	
/*Convert(DateTime,Floor(Cast((DateTime) as Float)),0) AS SummaryDate,
*/Interfaces.InterfaceId,
		Nodes.NodeID,
		Nodes.Caption AS NodeName,
		Nodes.VendorIcon AS Vendor_Icon,
		Interfaces.Caption AS Interface_Caption,
		Interfaces.InterfaceIcon AS Interface_Icon,
		Maxbps_In95,
		Maxbps_Out95,
		Maxbps_95
		
FROM Nodes
INNER JOIN Interfaces ON Nodes.NodeID = Interfaces.NodeID
INNER JOIN (
	SELECT	InterfaceID,
			 dbo.GetInBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_In95,
			 dbo.GetOutBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_Out95,
			 dbo.GetMaxBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_95
	FROM InterfaceTraffic
	WHERE InterfaceTraffic.DateTime >= @StartDate AND InterfaceTraffic.DateTime <= @EndDate
	GROUP BY InterfaceID
) TrafficStat
ON Interfaces.InterfaceID = TrafficStat.InterfaceID /*inner join InterfaceTraffic on trafficstat.InterfaceID = InterfaceTraffic.InterfaceID
*/
WHERE 
   (Interfaces.Caption LIKE '%TO LA%') OR 
   (Interfaces.Caption LIKE '%TKM%') OR 
   (Interfaces.Caption LIKE '%TLKM%') OR 
   (Interfaces.Caption LIKE '%XL%') OR 
   (Interfaces.Caption LIKE '%TELKOM%') OR 
   (Interfaces.Caption LIKE '%MPLS%')

/*GROUP BY Convert(DateTime,Floor(Cast((DateTime) as Float)),0), interfaces.InterfaceID, nodes.NodeID, nodes.Caption, nodes.VendorIcon, interfaces.caption, Interfaces.InterfaceIcon, trafficstat.Maxbps_95, trafficstat.Maxbps_In95, TrafficStat.Maxbps_Out95
*/
ORDER BY NodeName, Interface_Caption


and when i execute it, it gave a return that i expected, but then i want to add a date coloumn on the first coloumn, i have tried many thinks but still doesnt gave me what i want

is there any idea ??

gbritton
Aged Yak Warrior

662 Posts

Posted - 05/02/2014 :  12:18:01  Show Profile  Reply with Quote
Where do you want to get the date from?
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 05/02/2014 :  12:20:43  Show Profile  Reply with Quote
What is not working? Are you getting an error or unexpected results? Do you really have a column called DateTime? It's hard to tell what you trying to do because you've commented out most the query.

If you want to post your DDL, Sample data and expected output we can help you better. Here are some links that can help you provide that:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

cocofuc25
Starting Member

Indonesia
14 Posts

Posted - 05/02/2014 :  14:02:06  Show Profile  Reply with Quote
thanks for all reply

the query above only give me a result without any coloumn of date, and i want to add it, for instance, i would like to have a return as following

Date : 03/05/2014
InterfaceID : 309
NodeID : 380
NodeName : France
VendorIcon : Cisco
Interface Caption : Interface FastEthernet 1/0
Interface Icon : FastEthernet
MaxBps_In95 : 3892 bps
MaxBps_Out95 : 4932 bps
MaxBps_Max95 : 5540 bps

but what i get when execute the query i dont get Date coloumn on the result, and i need that coloumn to be added into the result for report purpose
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 05/02/2014 :  14:26:18  Show Profile  Reply with Quote
I hate to be captain obvious, but did you uncomment the column you want?
Go to Top of Page

cocofuc25
Starting Member

Indonesia
14 Posts

Posted - 05/05/2014 :  03:03:28  Show Profile  Reply with Quote
yes, if i uncomment the coloumn i want, the process query never stop and need to be stop forcely,

any idea ??
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000