<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Requesting help designing the query in a Query Layer in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/requesting-help-designing-the-query-in-a-query/m-p/421489#M24040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With some help on GIS Stack Exchange I found out what the problem was with the third query, I accidently cut out a SUM command from the CAIDI part when I was copying and pasting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Jul 2014 16:25:25 GMT</pubDate>
    <dc:creator>ClayDennis</dc:creator>
    <dc:date>2014-07-23T16:25:25Z</dc:date>
    <item>
      <title>Requesting help designing the query in a Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/requesting-help-designing-the-query-in-a-query/m-p/421488#M24039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am pulling data from our SQL database to show our SAIDI and SAIFI numbers visually for our operations department. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a functioning query that can pull in the needed data, and currently I use a labeling expression to perform the math from the basic data to give the numbers I need to show.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the query I am using:&lt;/P&gt;&lt;P&gt;SELECT Milsoft.dbo.Outage.Substation, Milsoft.dbo.Outage.Feeder, COUNT(Milsoft.dbo.Outage.OutageName) As Outages, SUM(Milsoft.dbo.Outage.CustomersOutInitially) AS MemOut, SUM((Milsoft.dbo.Outage.InterruptionDuration*Milsoft.dbo.Outage.CustomersOutInitially)) as Time, Milsoft.dbo.CustomerServedElement.Total As Members FROM Milsoft.dbo.Outage, Milsoft.dbo.CustomerServedElement WHERE (Milsoft.dbo.CustomerServedElement.Year='2014' AND (Milsoft.dbo.CustomerServedElement.DayOfYear='181')) AND(Milsoft.dbo.Outage.Feeder=Milsoft.dbo.CustomerServedElement.ElementName) AND (Milsoft.dbo.Outage.OutageStartTime &amp;gt;= '6/1/2014' AND Milsoft.dbo.Outage.OutageStartTime &amp;lt;= '6/30/2014') GROUP BY&amp;nbsp; Milsoft.dbo.Outage.Substation, Milsoft.dbo.Outage.Feeder, Milsoft.dbo.CustomerServedElement.Total&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can probably be cleaned up, I am just starting to learn this (previously used access database and its query wizard instead of building it like this).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to add the math for SAIDI, SAIFI, and CAIDI.&amp;nbsp; One of our IT guys said that as soon as the column name variable was declared I should be able to use that name in my query which lead to this:&lt;/P&gt;&lt;P&gt;SELECT Milsoft.dbo.Outage.Substation, Milsoft.dbo.Outage.Feeder, COUNT(Milsoft.dbo.Outage.OutageName) As Outages, SUM(Milsoft.dbo.Outage.CustomersOutInitially) AS MemOut, SUM((Milsoft.dbo.Outage.InterruptionDuration*Milsoft.dbo.Outage.CustomersOutInitially)) as Time, Milsoft.dbo.CustomerServedElement.Total As Members, (Time/60/Members) AS SAIDI, (MemOut/Members) AS SAIFI, (SAIDI/SAIDI) AS CAIDI FROM Milsoft.dbo.Outage, Milsoft.dbo.CustomerServedElement WHERE (Milsoft.dbo.CustomerServedElement.Year='2014' AND (Milsoft.dbo.CustomerServedElement.DayOfYear='181')) AND(Milsoft.dbo.Outage.Feeder=Milsoft.dbo.CustomerServedElement.ElementName) AND (Milsoft.dbo.Outage.OutageStartTime &amp;gt;= '6/1/2014' AND Milsoft.dbo.Outage.OutageStartTime &amp;lt;= '6/30/2014') GROUP BY&amp;nbsp; Milsoft.dbo.Outage.Substation, Milsoft.dbo.Outage.Feeder, Milsoft.dbo.CustomerServedElement.Total&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This throws the error Time is an invalid column name, and will throw a similar error if I change the name to something else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This lead to my third query:&lt;/P&gt;&lt;P&gt;SELECT Milsoft.dbo.Outage.Substation, Milsoft.dbo.Outage.Feeder, COUNT(Milsoft.dbo.Outage.OutageName) As Outages, SUM(Milsoft.dbo.Outage.CustomersOutInitially) AS MemOut, SUM((Milsoft.dbo.Outage.InterruptionDuration*Milsoft.dbo.Outage.CustomersOutInitially)) as Time, Milsoft.dbo.CustomerServedElement.Total As Members, (SUM((Milsoft.dbo.Outage.InterruptionDuration*Milsoft.dbo.Outage.CustomersOutInitially))/60/Milsoft.dbo.CustomerServedElement.Total) AS Saidi, (SUM(Milsoft.dbo.Outage.CustomersOutInitially)/Milsoft.dbo.CustomerServedElement.Total) AS Saifi, (((Milsoft.dbo.Outage.InterruptionDuration*Milsoft.dbo.Outage.CustomersOutInitially))/60/Milsoft.dbo.CustomerServedElement.Total)/(SUM(Milsoft.dbo.Outage.CustomersOutInitially)/Milsoft.dbo.CustomerServedElement.Total)) AS Caidi FROM Milsoft.dbo.Outage, Milsoft.dbo.CustomerServedElement WHERE (Milsoft.dbo.CustomerServedElement.Year='2014' AND (Milsoft.dbo.CustomerServedElement.DayOfYear='181')) AND(Milsoft.dbo.Outage.Feeder=Milsoft.dbo.CustomerServedElement.ElementName) AND (Milsoft.dbo.Outage.OutageStartTime &amp;gt;= '6/1/2014' AND Milsoft.dbo.Outage.OutageStartTime &amp;lt;= '6/30/2014') GROUP BY&amp;nbsp; Milsoft.dbo.Outage.Substation, Milsoft.dbo.Outage.Feeder, Milsoft.dbo.CustomerServedElement.Total&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This query says I have an error near FROM, unfortunately I have no idea what that error is.&amp;nbsp; Any suggestions on what I am doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 14:34:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/requesting-help-designing-the-query-in-a-query/m-p/421488#M24039</guid>
      <dc:creator>ClayDennis</dc:creator>
      <dc:date>2014-07-23T14:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Requesting help designing the query in a Query Layer</title>
      <link>https://community.esri.com/t5/data-management-questions/requesting-help-designing-the-query-in-a-query/m-p/421489#M24040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With some help on GIS Stack Exchange I found out what the problem was with the third query, I accidently cut out a SUM command from the CAIDI part when I was copying and pasting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 16:25:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/requesting-help-designing-the-query-in-a-query/m-p/421489#M24040</guid>
      <dc:creator>ClayDennis</dc:creator>
      <dc:date>2014-07-23T16:25:25Z</dc:date>
    </item>
  </channel>
</rss>

