This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Report Writer SQL query help

Ok I need some help with a SQL Queuery.


 I need to be able to filter this query and I dont' know how to do this.


SELECT Caption,VendorIcon,Ip_Address,
DateDiff(hour,Nodes.LastBoot,GetDate()) AS HoursUp
FROM Nodes
ORDER BY 1 ASC


 


How would you just pull the custom property or a specific location from all the nodes?


 


Thanks for any help in advance


prof.

  • I think what you are looking for is a WHERE clause.


     


    SELECT Caption,VendorIcon,Ip_Address,
    DateDiff(hour,Nodes.LastBoot,GetDate()) AS HoursUp
    FROM Nodes


    WHERE Location = 'usa' 



    ORDER BY 1 ASC

  • Thanks for the help but I am getting an invalid column heading error when trying to run this


    SELECT Caption,VendorIcon,Ip_Address,
    DateDiff(hour,Nodes.LastBoot,GetDate()) AS HoursUp
    FROM Nodes
    WHERE Location = "Data Center SEV1"
    ORDER BY 1 ASC


     


    Sorry, I am not a sql guru in the least.


    Thanks again 


    Prof


  • In the WHERE clause above, Location is the name of the field in the nodes table that contains the information "Data Center SEV1".  For example, if the name of this field in your nodes table is called Site then the where clause would look like:


    WHERE Site = 'Data Center SEV1' 

  • Also, make sure you are using single quotes and not double quotes in your WHERE clause.

  • Thanks a bunch that seemed to work like a charm. Must have been the double quotes since I changed that it works great.


     


    Now I have 1 more need if it is not any trouble for all the SQL gurus.


    How can I pull just the data from 6AM - 9PM or 0600 - 2100 hours Monday through Sat. I don't need to report anything after 9:00 PM or anygthing on Sunday. Any help would be greatly appreciated.


     


    prof

  • You're gonna have to help us help you. What kind of data are you looking for? Do you have a sample SQL query like the one in your original post?
  • What I have is this


     SELECT Caption,Location, VendorIcon,Ip_Address,
    DateDiff(hour,Nodes.LastBoot,GetDate()) AS HoursUp
    FROM Nodes
    WHERE Location = 'Data Center SEV1' 


    ORDER BY 1 ASC


    Now from that I only need to have the data from the hours -


    greater then or equal to 0600 and


    less then or equal to 2100 hrs but not on a day equal to Sunday. That is what I don't know how to do with a direct SQL query where if this was donw with the regular report writer expressions you can specify that in the filters.


    Any help would be greatly appreciated and sure would help other too.


    prof


    So the hours would only be for Mon. - Sat. 6am to 9PM.  

  • Are you saying you only want to select the records where the LastBoot time was Monday - Saturday 6a.m. - 9p.m. ?

  • What I am trying to get is a report that only shows downtime Monday - Sat. from 6:00AM to 9:00 PM and does not report downtime outside of those times per an SLA that we have.


    I had thought that this report would show this with some modifications. If I am barking up the wrong tree then that is where I need the help on figuring out how to do this.


     


    Thanks


    prof

  • Ok, let me see if I understand this correctly. You want a report that displays all nodes that went down within the last seven days (excluding Sunday) between 6AM and 9PM?