<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel>
	  <title>Ask MetaFilter questions tagged with sql</title>
      <link>http://ask.metafilter.com/tags/sql</link>
      <description>Questions tagged with 'sql' at Ask MetaFilter.</description>
	  <pubDate>Thu, 19 Nov 2009 11:37:28 -0800</pubDate> <lastBuildDate>Thu, 19 Nov 2009 11:37:28 -0800</lastBuildDate>

      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>	  
	<item>
	<title>What interesting statistical information can I dig out of this medical billing data?</title>
	<link>http://ask.metafilter.com/138564/What%2Dinteresting%2Dstatistical%2Dinformation%2Dcan%2DI%2Ddig%2Dout%2Dof%2Dthis%2Dmedical%2Dbilling%2Ddata</link>	
	<description>What interesting statistical information can I dig out of this medical billing data? I have 2000 rows of medical billing information (mysql) with the following attributes.  I&apos;ve normalized the data and here is a very simple description:&lt;br&gt;
&lt;br&gt;
patient:&lt;br&gt;
id&lt;br&gt;
dob&lt;br&gt;
city/state/zip&lt;br&gt;
primary insurance provider&lt;br&gt;
secondary insurance provider&lt;br&gt;
&lt;br&gt;
provider:&lt;br&gt;
id&lt;br&gt;
&lt;br&gt;
procedure:&lt;br&gt;
procedure id/code&lt;br&gt;
&lt;br&gt;
patient_procedure:(fk to patient &amp;amp; provider &amp;amp; procedure)&lt;br&gt;
procedure date&lt;br&gt;
billed amount&lt;br&gt;
&lt;br&gt;
Unfortunately, the data only spans one month so I can&apos;t provide anything interesting across a date dimension beyond aggregating certain measures by weekday. &lt;br&gt;
&lt;br&gt;
I&apos;ve already produced a lot of information such as&lt;br&gt;
% of patients with no secondary insurance&lt;br&gt;
avg age for procedure&lt;br&gt;
top-5 most frequently occurring procedures with large avg cost&lt;br&gt;
billing  and frequency by zipcode&lt;br&gt;
so on and so forth-measure X across dimension Y&lt;br&gt;
&lt;br&gt;
I&apos;m looking for suggestions for some deeper analysis than the many SQL aggregates that I&apos;ve performed.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.138564</guid>
	<pubDate>Thu, 19 Nov 2009 11:37:28 -0800</pubDate>
	<category>analysis</category>
	<category>data</category>
	<category>mysql</category>
	<category>sql</category>
	<category>statistics</category>
	<dc:creator>neilkod</dc:creator>
	</item>
	<item>
	<title>2 Fields, 1 Query</title>
	<link>http://ask.metafilter.com/137772/2%2DFields%2D1%2DQuery</link>	
	<description>SQLfilter: Trying to sum and count  two fields contained within the table by specifying criteria (more inside). I have two fields a service_number field and a minutes field.&lt;br&gt;
&lt;br&gt;
 I need two operations performed at once, I need to count the service_number field and sum the minutes field.&lt;br&gt;
&lt;br&gt;
BUT I need to do it where the minutes field is less than 1000. I also need the same information where the minutes field is between 1001 and 2000 and where the minutes field is between 2001 and 3000...and so on, and I need it all done in 1 query.&lt;br&gt;
&lt;br&gt;
I&apos;ve been trying to do this all day, SQL Guru&apos;s do your magic.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.137772</guid>
	<pubDate>Tue, 10 Nov 2009 15:23:42 -0800</pubDate>
	<category>operations</category>
	<category>sql</category>
	<dc:creator>kasperj74</dc:creator>
	</item>
	<item>
	<title>Need recs for IT training in Seattle.</title>
	<link>http://ask.metafilter.com/136952/Need%2Drecs%2Dfor%2DIT%2Dtraining%2Din%2DSeattle</link>	
	<description>In the Seattle/Snohomish area. Which schools provide good training in beginning SQL, or database design, or IT project management? Needs:&lt;br&gt;
- School should be well-regarded by hiring managers and look good on my resume&lt;br&gt;
- Training should be rigorous. Prefer a fast-paced class. &lt;br&gt;
- Location: North or central Seattle are good. Or Everett/Lynnwood area. I live in Shoreline/Edmonds. &lt;br&gt;
- Hoping to start training asap. I am unemployed and have time to study. Don&apos;t want to wait until Winter semester. &lt;br&gt;
&lt;br&gt;
Here is a &lt;a href=&quot;http://www.computerschools.com/cities/seattle-computer-training-institutes-schools.html&quot;&gt;listing of Seattle computer training schools&lt;/a&gt;. Which ones have a good rep and do a good job?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.136952</guid>
	<pubDate>Sat, 31 Oct 2009 20:35:39 -0800</pubDate>
	<category>database</category>
	<category>edmonds</category>
	<category>education</category>
	<category>everett</category>
	<category>it</category>
	<category>school</category>
	<category>seattle</category>
	<category>snohomish</category>
	<category>sql</category>
	<category>training</category>
	<dc:creator>valannc</dc:creator>
	</item>
	<item>
	<title>MS SQL please speed up so i dont cry</title>
	<link>http://ask.metafilter.com/135937/MS%2DSQL%2Dplease%2Dspeed%2Dup%2Dso%2Di%2Ddont%2Dcry</link>	
	<description>MS SQL Pros, I need your help!  What&apos;s causing MS SQL 2005 to import records so slowly?  It&apos;s a persistent problem across all databases that just developed yesterday.  Details inside... So my 3rd party app that I use to import records into MS SQL 2005 Standard has gone from approximately 10K records per hour to 500 records per hour.  I&apos;ve tried creating new databases to test on, and they all give me the same result.&lt;br&gt;
&lt;br&gt;
I&apos;m no MS SQL expert, but I did a bit of googling and created a trace file.  It looks like the delay (according to the Start and End Time in the trace record) is between an &quot;IF @@TRANCOUNT &amp;gt; 0 COMMIT TRAN&quot; and &quot;SELECT ID FROM tlbFolders WHERE NAME=&quot;C:\PATHTODATA\&quot;.  The delay between these 2 events is about 10 seconds, and I can&apos;t tell why it&apos;s acting so slow.&lt;br&gt;
&lt;br&gt;
I&apos;ll follow up in the thread, let me know if you need more info or know of any additional resources that can help me answer this question, or any good troubleshooting tips.  Thanks!</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.135937</guid>
	<pubDate>Tue, 20 Oct 2009 09:07:43 -0800</pubDate>
	<category>MSSQL</category>
	<category>SQL</category>
	<dc:creator>antonymous</dc:creator>
	</item>
	<item>
	<title>Finding rows that don&apos;t exist in an SQL Server 2005 table</title>
	<link>http://ask.metafilter.com/134873/Finding%2Drows%2Dthat%2Ddont%2Dexist%2Din%2Dan%2DSQL%2DServer%2D2005%2Dtable</link>	
	<description>I can&apos;t seem to build a query in SQL Server 2005 that returns rows that are &lt;em&gt;not&lt;/em&gt; in a table. I have a table called &lt;code&gt;sch&lt;/code&gt; that includes student IDs and the periods for which the students are scheduled:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;period&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Table &lt;code&gt;att&lt;/code&gt; includes student IDs and the dates and periods they attended:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;period&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-01&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-01&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-01&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-01&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-01&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-02&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-02&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-02&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-02&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-03&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-03&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-03&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-03&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
In this example, the attendance for student 111, period 4, is missing for 2009-10-02 and 2009-10-03. How can I build a query to get that result? Ideally, the query would return:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;period&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-02&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
111&amp;nbsp;&amp;nbsp;&amp;nbsp;2009-10-03&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
I&apos;ve tried a &lt;code&gt;left join&lt;/code&gt; on the tables between the IDs and periods but it&apos;s not getting me what I need. Any help is appreciated.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.134873</guid>
	<pubDate>Wed, 07 Oct 2009 12:24:41 -0800</pubDate>
	<category>sql</category>
	<category>sqlserver</category>
	<dc:creator>DakotaPaul</dc:creator>
	</item>
	<item>
	<title>How does WITH work in MS SQL Server?</title>
	<link>http://ask.metafilter.com/132620/How%2Ddoes%2DWITH%2Dwork%2Din%2DMS%2DSQL%2DServer</link>	
	<description>Can someone help me understand how the &lt;code&gt;WITH&lt;/code&gt; common table expression works in Microsoft SQL Server? I&apos;d like to learn more about how the &lt;code&gt;WITH&lt;/code&gt; common table expression works in Microsoft SQL Server. I saw an example in the &lt;a href=&quot;http://oreilly.com/catalog/9780596009762/&quot;&gt;SQL Cookbook&lt;/a&gt;, but don&apos;t quite understand it. Can one of you SQL gurus break it down a bit for me?&lt;br&gt;
&lt;br&gt;
Here&apos;s the data in the &lt;code&gt;emp&lt;/code&gt; table:&lt;blockquote&gt;&lt;code&gt;&lt;br&gt;
deptno&amp;nbsp;&amp;nbsp;ename&lt;br&gt;
------&amp;nbsp;&amp;nbsp;--------&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;CLARK&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;KING&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;MILLER&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&amp;nbsp;&amp;nbsp;FORD&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&amp;nbsp;&amp;nbsp;ADAMS&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&amp;nbsp;&amp;nbsp;MARTIN&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&amp;nbsp;&amp;nbsp;BLAKE&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&amp;nbsp;&amp;nbsp;ALLEN&lt;br&gt;
&lt;/code&gt;&lt;/blockquote&gt;The &lt;code&gt;WITH&lt;/code&gt; common table expression:&lt;blockquote&gt;&lt;code&gt;&lt;br&gt;
with x (deptno, cnt, names, empno, len) as &lt;br&gt;
(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select deptno, count(*) over (partition by deptno),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cast(ename as varchar(100)),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;empno, 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;from emp&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;union all&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select x.deptno, x.cnt,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cast(x.names + &apos;,&apos; + e.ename as varchar(100)),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.empno, x.len+1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;from emp e, x&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where e.deptno = x.deptno and e.empno &amp;gt; x.empno&lt;br&gt;
)&lt;br&gt;
select deptno, names&lt;br&gt;
from x&lt;br&gt;
where len = cnt&lt;br&gt;
order by 1&lt;br&gt;
&lt;/code&gt;&lt;/blockquote&gt;The results:&lt;blockquote&gt;&lt;code&gt;&lt;br&gt;
deptno&amp;nbsp;&amp;nbsp;names&lt;br&gt;
------&amp;nbsp;&amp;nbsp;----------------------&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp;CLARK,&amp;nbsp;KING,&amp;nbsp;MILLER&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&amp;nbsp;&amp;nbsp;FORD,&amp;nbsp;ADAMS&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&amp;nbsp;&amp;nbsp;MARTIN,&amp;nbsp;BLAKE,&amp;nbsp;ALLEN&lt;br&gt;
&lt;/code&gt;&lt;/blockquote&gt;</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.132620</guid>
	<pubDate>Fri, 11 Sep 2009 15:05:43 -0800</pubDate>
	<category>sql</category>
	<category>sqlserver</category>
	<dc:creator>DakotaPaul</dc:creator>
	</item>
	<item>
	<title>SQL Challenge</title>
	<link>http://ask.metafilter.com/128424/SQL%2DChallenge</link>	
	<description>SQL question: Getting all records based on a row-specific criteria There are some number of processes that execute on a somewhat random schedule. When the process starts, we insert a record with the StartTime and a null EndTime / Succeeded value. If the process finishes, it updates the EndTime and Succeeded columns. But sometimes the process hangs/dies and never updates its record. We&apos;d like to be able to distinguish between &quot;Things which are probably still running&quot; and &quot;Things which probably died&quot;.&lt;br&gt;
&lt;br&gt;
My schema looks like this:&lt;br&gt;
&lt;pre&gt;ResultID    ProcessName     StartTime      EndTime      Succeeded&lt;br&gt;
--------    -----------     ---------      -------      ---------&lt;br&gt;
0           BuildWidgets    7:20 PM        7:25 PM      True&lt;br&gt;
1           BuildWidgets    7:20 PM        7:28 PM      False&lt;br&gt;
2           BuildWidgets    3:50 PM        3:55 PM      True&lt;br&gt;
3           BuildSprockets  4:20 PM        5:25 PM      True&lt;br&gt;
4           BuildWidgets    9:50 PM        NULL         NULL&lt;br&gt;
5           BuildSprockets  9:30 PM        NULL         NULL&lt;/pre&gt;&lt;br&gt;
I want to have a stored procedure update this table every few minutes and sets Succeeded = false for all the records where it&apos;s taken longer than any prior succeeded instance of that ProcessName. In this example, when BuildWidgets passes, it always takes at most 5 minutes, whereas BuildSprockets might take an hour. For example, at 10:00 PM, we&apos;d update the ResultID 4 BuildWidgets Passed = False, but leave the ResultID 5 BuildSprockets row alone since it might still be running.&lt;br&gt;
&lt;br&gt;
SQL Server 2005 if it matters</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.128424</guid>
	<pubDate>Sun, 26 Jul 2009 12:52:16 -0800</pubDate>
	<category>resolved</category>
	<category>sql</category>
	<dc:creator>0xFCAF</dc:creator>
	</item>
	<item>
	<title>(MS)SQL Query within a Query</title>
	<link>http://ask.metafilter.com/128151/MSSQL%2DQuery%2Dwithin%2Da%2DQuery</link>	
	<description>I have a basic sql query which returns all jobs run between specified dates as follows:
SELECT   job_id, starttime, size
FROM      job_history
WHERE   (starttime &amp;gt; FromDate) AND (startTime &amp;lt; ToDate)

But I also want the query to return the previous size for that job_id I&apos;ve tried:&lt;br&gt;
SELECT   job_id, starttime, size,&lt;br&gt;
  (SELECT Top 1 size FROM job_history&lt;br&gt;
  WHERE starttime [less than] FromDate &lt;br&gt;
  AND job_id = job_id&lt;br&gt;
  ORDER BY starttime DESC) AS Previous_Size&lt;br&gt;
FROM      job_history&lt;br&gt;
WHERE   (starttime &amp;gt; FromDate) AND (startTime [less than] ToDate)&lt;br&gt;
&lt;br&gt;
I&apos;m guessing that I need a variable in ther or something but I&apos;m a bit out of my depth.&lt;br&gt;
&lt;br&gt;
([less than] used to indicate opposite of &amp;gt; as it seems to dissapear when posted.)</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.128151</guid>
	<pubDate>Thu, 23 Jul 2009 01:09:28 -0800</pubDate>
	<category>resolved</category>
	<category>SQL</category>
	<dc:creator>xla76</dc:creator>
	</item>
	<item>
	<title>SQL query problem</title>
	<link>http://ask.metafilter.com/127685/SQL%2Dquery%2Dproblem</link>	
	<description>I need to write a query that will return the largest value of one column for each unique value in another column. Example included. Given this table:&lt;br&gt;
&lt;br&gt;
NAME   SALARY&lt;br&gt;
Smith  5&lt;br&gt;
Smith  22&lt;br&gt;
Adam 55&lt;br&gt;
Jones  12&lt;br&gt;
Jones  10&lt;br&gt;
Smith  21&lt;br&gt;
Smith 4&lt;br&gt;
&lt;br&gt;
how would you return one row per NAME with the largest value of SALARY for that name:&lt;br&gt;
&lt;br&gt;
NAME   SALARY&lt;br&gt;
Adam 55&lt;br&gt;
Jones  12&lt;br&gt;
Smith  22</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.127685</guid>
	<pubDate>Fri, 17 Jul 2009 07:35:10 -0800</pubDate>
	<category>resolved</category>
	<category>sql</category>
	<dc:creator>davcoo</dc:creator>
	</item>
	<item>
	<title>Help ADDS Synchronize users to SQL</title>
	<link>http://ask.metafilter.com/127625/Help%2DADDS%2DSynchronize%2Dusers%2Dto%2DSQL</link>	
	<description>How to make Active Directory and SQL server synchronize User accounts/passwords. Windows: 2008 ADDS&lt;br&gt;
SQL: 2005&lt;br&gt;
&lt;br&gt;
Our bread and butter software requires users to be setup in its database for permissions.  It&#8217;s a total pain in the ass managing 1200 users in both ADDS and SQL.  Many times passwords get out of synch.  We are looking for software/method to synchronize ADDS to SQL.  &lt;br&gt;
Any ideas?&lt;br&gt;
&lt;br&gt;
Thanks!</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.127625</guid>
	<pubDate>Thu, 16 Jul 2009 13:13:37 -0800</pubDate>
	<category>ADDS</category>
	<category>SQL</category>
	<category>Synchronization</category>
	<category>User</category>
	<dc:creator>bleucube</dc:creator>
	</item>
	<item>
	<title>How can I get the result of mysql_fetch_array to skip a row?</title>
	<link>http://ask.metafilter.com/125978/How%2Dcan%2DI%2Dget%2Dthe%2Dresult%2Dof%2Dmysqlfetcharray%2Dto%2Dskip%2Da%2Drow</link>	
	<description>Tearing my hair out over what feels like a simple PHP/SQL question: mysql_fetch_array returns, dur, an array of all the rows that matched your query. How can I tell it to skip a row of that array? More inside. Basically, I&apos;m fetching a bunch of rows for display. The FIRST of these rows completes a  row in am html table. ANY OTHER ROW that it gets will be in a new  table row. &lt;br&gt;
&lt;br&gt;
I catch it like so:&lt;br&gt;
&lt;br&gt;
 $query_lots=&quot;SELECT * FROM lots_new WHERE lot_sku_id=&apos;$curr_key&apos;&quot;;&lt;br&gt;
&lt;br&gt;
$lots_result=mysql_query($query_lots) or die(mysql_error());&lt;br&gt;
&lt;br&gt;
So, I need to say &quot;With Row 1, do this. If there are other Rows, do that&quot;.&lt;br&gt;
&lt;br&gt;
So, how can I say: $lots_result START WITH YOUR SECOND ROW OF RESULTS.&lt;br&gt;
&lt;br&gt;
I cannot find an answer to this anywhere and I am going craaaaaazy. Thoughts/help?!</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.125978</guid>
	<pubDate>Sat, 27 Jun 2009 17:25:49 -0800</pubDate>
	<category>array</category>
	<category>php</category>
	<category>sql</category>
	<dc:creator>GilloD</dc:creator>
	</item>
	<item>
	<title>In SQL, how do I use the results of a SELECT to perform row-specific UPDATEs?</title>
	<link>http://ask.metafilter.com/123561/In%2DSQL%2Dhow%2Ddo%2DI%2Duse%2Dthe%2Dresults%2Dof%2Da%2DSELECT%2Dto%2Dperform%2Drowspecific%2DUPDATEs</link>	
	<description>In SQL, how do I use the results of a &lt;code&gt;SELECT&lt;/code&gt; to perform row-specific &lt;code&gt;UPDATE&lt;/code&gt;s? I&apos;m looking to slightly denormalize a relatively normalized set of tables, namely &lt;code&gt;myclasses&lt;/code&gt;, &lt;code&gt;myusers&lt;/code&gt;, and a many-to-many table called &lt;code&gt;myclassestomyusers&lt;/code&gt;, by putting the name of the instructor (in &quot;LASTNAME, Firstname&quot; format) back into an empty column named &lt;code&gt;Instructor&lt;/code&gt; in &lt;code&gt;myclasses&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
Note: This is a toy example of a vendor app and database.  Yeah, I know denormalizing is naughty.  It is what is required here, so that&apos;s that.&lt;br&gt;
&lt;br&gt;
I have a nice little command which does the appropriate &lt;code&gt;JOINS&lt;/code&gt; and spits out instructor names in the format required.  However, I do not know how to appropriately weld this to an &lt;code&gt;UPDATE&lt;/code&gt;: &lt;br&gt;
&lt;br&gt;
&lt;code&gt;SELECT UPPER(myusers.lastname) + &apos;, &apos; + myusers.firstname AS InstName&lt;br&gt;
FROM myclasses&lt;br&gt;
INNER JOIN myclassestomyusers&lt;br&gt;
ON myclasses.classid = myclassestomyusers.classid&lt;br&gt;
INNER JOIN myusers&lt;br&gt;
ON myclassestomyusers.userid = myusers.userid&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;code&gt;UPDATE myclasses&lt;br&gt;
SET myclasses.Instructor = &lt;em&gt;???what???&lt;/em&gt;&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Obviously, I can do this programmatically.  I&apos;d like to do it at a stroke: a SQL command or two, partially to know it can be done, but also for my own learning experience.  &lt;br&gt;
&lt;br&gt;
Additionally, what is this technique &lt;em&gt;called&lt;/em&gt;?  I&apos;ve flipped through Joe Celko&apos;s &lt;i&gt;SQL Puzzles&lt;/i&gt; looking for something relevant but have found nothing appropriate (or have been unable to recognize it).</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.123561</guid>
	<pubDate>Mon, 01 Jun 2009 08:37:00 -0800</pubDate>
	<category>sql</category>
	<category>update</category>
	<dc:creator>adipocere</dc:creator>
	</item>
	<item>
	<title>How to keep track of many computers?</title>
	<link>http://ask.metafilter.com/121528/How%2Dto%2Dkeep%2Dtrack%2Dof%2Dmany%2Dcomputers</link>	
	<description>I need an inventory management system to keep track of computer hardware and its users. Here&apos;s a simplified description:&lt;br&gt;
I&apos;ve got 500 computers, 300 monitors, 200 people, and 100 offices. I want to assign a unique identifier (UID) and barcode to each.&lt;br&gt;
&lt;br&gt;
I want a database of these UIDs, so I can do a query and know that Computer 123 and Monitor 257 are in Office 23 and used by User 12. And if Computer 123 and Monitor 257 are moved to Office 17 I want to be able to update the database. And, when needed, get a printout of the database and know where everything is and who&apos;s using it. When I get a new computer, I create a new UID, print a new barcode based on that UID, scan the barcode, and import it into the database.&lt;br&gt;
&lt;br&gt;
So I think I&apos;ll need 1) software to create the barcodes and manage the UID database, and 2) hardware: scanner/PDA to scan and printer to print the barcodes.&lt;br&gt;
&lt;br&gt;
Our backend infrastructure is Unix so I won&apos;t buy MS-SQL Server and would rather not be locked in to proprietary or M$ software. Big bonus if it&apos;ll play nice with Apache and MySQL. Bigger bonus if I can put a web front end on the database.&lt;br&gt;
&lt;br&gt;
I would appreciate some suggestions for vendors, solutions, and implementation ideas.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.121528</guid>
	<pubDate>Thu, 07 May 2009 13:19:07 -0800</pubDate>
	<category>barcode</category>
	<category>database</category>
	<category>sql</category>
	<dc:creator>the matching mole</dc:creator>
	</item>
	<item>
	<title>Oracle Views: Are calculated columns always evaluated even when they are not considered in a query?</title>
	<link>http://ask.metafilter.com/120110/Oracle%2DViews%2DAre%2Dcalculated%2Dcolumns%2Dalways%2Devaluated%2Deven%2Dwhen%2Dthey%2Dare%2Dnot%2Dconsidered%2Din%2Da%2Dquery</link>	
	<description>Oracle Views: Are calculated columns always evaluated even when they are not considered in a query? I&apos;d like some advice regarding Oracle views. Are fields always evaluated regardless of whether they are required in the results set?&lt;br&gt;
&lt;br&gt;
Let&apos;s say I have tables PRODUCTS and ORDERS. And I create a view called PRODUCTS_VIEW which consists of something like:&lt;br&gt;
&lt;br&gt;
SELECT &lt;br&gt;
	PRODUCT.ID, &lt;br&gt;
	PRODUCT.NAME,&lt;br&gt;
	fcnGetMostRecentOrderDate(PRODUCT.ID) AS MostRecentOrderDate,&lt;br&gt;
	fcnGetTotalOrdersCount(PRODUCT.ID) AS TotalOrdersCount,&lt;br&gt;
	fcnGetMaxOrderVolumn(PRODUCT.ID) AS MaxOrderVolumn&lt;br&gt;
        and so on&lt;br&gt;
FROM&lt;br&gt;
     PRODUCTS,&lt;br&gt;
     ORDERS&lt;br&gt;
&lt;br&gt;
I.e. a flat view that encapsulates all possible attributes--I estimate around 20 static and 60 calculated fields.&lt;br&gt;
&lt;br&gt;
This is for reporting purposes, either queried directly or perhaps wrapped up in an API. Maintainability is important, if I need a new attribute then I can easily add a new field as necessary. Performance is certainly a factor but, since it&apos;s only for reporting purposes, there is a degree of flexibility.&lt;br&gt;
&lt;br&gt;
If I run a query that only considers 2 or 3 fields e.g.&lt;br&gt;
&lt;br&gt;
SELECT PRODUCT.NAME, MostRecentOrderDate&lt;br&gt;
 FROM PRODUCTS_VIEW &lt;br&gt;
WHERE... say....CLIENT = Heinz&lt;br&gt;
&lt;br&gt;
Would it still evaluate *all* the other calculated fields? (I think it does unfortunately: and I&apos;m concerned that performance would degrade as new fields are added.)&lt;br&gt;
&lt;br&gt;
If it *does* behave thus is there a way around it? I suppose a materialized view is an option. Or is this an inappropriate use? I am avoiding dynamic SQL since I would rather consolidate the logic into something that can be made (easily) accessible through ODBC, ADO, a bundle of Web Service methods etc. Note that a data warehouse approach (e.g. a daily dump of denormalised data) is not appropriate since data updates need to reflected immediately.&lt;br&gt;
&lt;br&gt;
Thanks.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.120110</guid>
	<pubDate>Tue, 21 Apr 2009 14:14:16 -0800</pubDate>
	<category>datawarehouse</category>
	<category>materializedview</category>
	<category>oracle</category>
	<category>resolved</category>
	<category>SQL</category>
	<category>view</category>
	<dc:creator>NailsTheCat</dc:creator>
	</item>
	<item>
	<title>MS Access / SQL help please?</title>
	<link>http://ask.metafilter.com/120072/MS%2DAccess%2DSQL%2Dhelp%2Dplease</link>	
	<description>I have a (hopefully easy) SQL question. I&apos;m working in MS Access. Simplifying things a bit, I have a table with a TaskID, and a TaskStatusID. I want to get a list of each TaskID, and the newest TaskStatusID for each. (Details follow.) The idea is a single task can have multiple statuses. My data looks like this:&lt;br&gt;
TaskID = 1, TaskStatusID = 1&lt;br&gt;
TaskID = 1, TaskStatusID = 2&lt;br&gt;
TaskID = 1, TaskStatusID = 3&lt;br&gt;
TaskID = 2, TaskStatusID = 4&lt;br&gt;
TaskID = 2, TaskStatusID = 5&lt;br&gt;
TaskID = 3, TaskStatusID = 6&lt;br&gt;
TaskID = 4, TaskStatusID = 7&lt;br&gt;
&lt;br&gt;
I want to get a list of each TaskID, and the newest TaskStatusID for each. So, I want a query that will return this:&lt;br&gt;
TaskID = 1, TaskStatusID = 3&lt;br&gt;
TaskID = 2, TaskStatusID = 5&lt;br&gt;
TaskID = 3, TaskStatusID = 6&lt;br&gt;
TaskID = 4, TaskStatusID = 7&lt;br&gt;
&lt;br&gt;
The goal is to show that on a Continuous Form. I don&apos;t think this should be that difficult, but I&apos;m learning as I go and just can&apos;t wrap my head around what the query should be. Any suggestions please? Thanks!</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.120072</guid>
	<pubDate>Tue, 21 Apr 2009 07:03:38 -0800</pubDate>
	<category>Access</category>
	<category>resolved</category>
	<category>SQL</category>
	<dc:creator>inigo2</dc:creator>
	</item>
	<item>
	<title>SQL Query Question</title>
	<link>http://ask.metafilter.com/119665/SQL%2DQuery%2DQuestion</link>	
	<description>SQL query help. Given the (fictional but equivalent) table disk_status = computer_id:int, disk_id:int, datetime:datetime, temperature:float, rpm:int, I need to provide a table of disk status for a given computer_id, without knowing in advance how many disks there are. So if there were two disks for a particular computer, the result would have the header: datetime, disk_1_temperature, disk_1_rpm, disk_2_temperature, disk_2_rpm, disk_2_rpm Long story short (and continuing with the computer/disk example) in the past we only ever needed to track one disk per computer, and so we did not use a disk_id at all. When faced with multiple disks, I considered adding more columns (disk_2_temp, etc) but there may be many, and that seemed like a hack. Instead I added the disk_id column, but now I need a way to get the data out in the right format. &lt;br&gt;
&lt;br&gt;
Currently I do two queries: one to determine which disks are available, and then I left join the disk_status table to itself once for each disk:&lt;br&gt;
&lt;br&gt;
SELECT disk_1.*, disk2.*&lt;br&gt;
FROM disk_status AS disk_1&lt;br&gt;
LEFT JOIN disk_status AS disk_2 &lt;br&gt;
ON disk_2.computer_id=x &lt;br&gt;
AND disk_2.disk_id=z &lt;br&gt;
AND disk_2.datetime = disk_1.datetime&lt;br&gt;
LEFT JOIN disk_status AS disk_3 &lt;br&gt;
...&lt;br&gt;
WHERE disk_1.computer_id = x&lt;br&gt;
AND disk_1.disk_id = y&lt;br&gt;
&lt;br&gt;
This seems inefficient. It also fails if disk_1 does not report but disk_2 does (disk_2 gets left out too). Is there a better way? Or is there a better way to structure my table?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.119665</guid>
	<pubDate>Thu, 16 Apr 2009 06:10:00 -0800</pubDate>
	<category>computer</category>
	<category>database</category>
	<category>joins</category>
	<category>mysql</category>
	<category>sql</category>
	<dc:creator>Nothing</dc:creator>
	</item>
	<item>
	<title>Copy-Down in SQL</title>
	<link>http://ask.metafilter.com/119554/CopyDown%2Din%2DSQL</link>	
	<description>Is there a GUI SQL editor that emulates a spreadsheet-style &quot;copy down&quot;? If not, is there a technique I should learn? I seem to spend 10-15 mins a day touching up some mysql data in a huge remote CRM-type database (I don&apos;t have shell access) and I notice that I spend most of that time copy-pasting the same corrections down one column for 50 or 60 rows. (I do a select to find new stuff, eyeball it, and find that one of the records has the right info and the other fifty need to be made the same, or none are right and I need to change them all). &lt;br&gt;
&lt;br&gt;
If I was using a spreadsheet like Excel, that would take 2 seconds (drag down a range, control-d duplicate), but I haven&apos;t found a GUI SQL editor that can do this, so I click-copy-paste-click for 15 mins. This is time-wastey and feels silly. There&apos;s got to be an easier way.&lt;br&gt;
&lt;br&gt;
(I realize that technically the app would have to do 60 individual updates, but that would be behind the scenes while I move on to more fun parts of my day, right?)&lt;br&gt;
&lt;br&gt;
So is there a GUI SQL app that emulates the &quot;copy down&quot; of spreadsheets? Or if I were more clueful, is there a stored statement or &quot;macro&quot; I could make in one of these things that would take the selected field in the current record and dupe it down down down? If so, kick me in the right direction: I&apos;m no database geek but I&apos;m not wholly useless technically, either. I can probably learn from a few examples. (15 mins a day times 200 days a year is enough time to be worth reading a book!)&lt;br&gt;
&lt;br&gt;
I&apos;d prefer OSX but I would use Windows or Linux for a few minutes per day if the right tool is out there. For OSX, I&apos;ve tried out the official mysql client, RazorSQL, Navicat, SequelPro, and SQLgrinder. Some are better than others at the copy-paste and ad hoc correcting I do, but none have &quot;duplicate down&quot;.&lt;br&gt;
&lt;br&gt;
These seems simple enough (to my pretty little head) that I must be missing something.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.119554</guid>
	<pubDate>Tue, 14 Apr 2009 22:36:40 -0800</pubDate>
	<category>controld</category>
	<category>copydown</category>
	<category>duplicate</category>
	<category>mysql</category>
	<category>qui</category>
	<category>sql</category>
	<dc:creator>rokusan</dc:creator>
	</item>
	<item>
	<title>There&apos;s got to be a faster way to update</title>
	<link>http://ask.metafilter.com/117908/Theres%2Dgot%2Dto%2Dbe%2Da%2Dfaster%2Dway%2Dto%2Dupdate</link>	
	<description>Please help me simplify a complicated mysql update I have a giant database with data nested in 3 levels. Year (00-07), time (1-15) and location (1-125000)&lt;br&gt;
&lt;br&gt;
Let&apos;s say I have a field called &lt;strong&gt;z&lt;/strong&gt;. I am trying to add a field called &lt;strong&gt;cumulative z &lt;/strong&gt; (by year) with each record.&lt;br&gt;
&lt;br&gt;
My current approach to inserting cumulative z values is as follows:&lt;br&gt;
&lt;br&gt;
For the sake of tractability, I have split the data into separate tables for each year.&lt;br&gt;
&lt;br&gt;
Using PHP, I have 2 nested loops (time and location). &lt;br&gt;
&lt;br&gt;
Within the inner loop, the following happens:&lt;br&gt;
&lt;br&gt;
If time is 1, then cumulative z= z for that location.&lt;br&gt;
&lt;br&gt;
if time&amp;gt;1&lt;br&gt;
&lt;br&gt;
then cumulative z= z+cumulative z for time t-1.  This step is the bottleneck. I have to write another query statement to find out what cum z was for the same location at t-1. &lt;br&gt;
&lt;br&gt;
The query takes very long for each location. I estimate that it will take several days to do this for a single year. There must be a faster way.  Can any SQL gurus offer suggestion to make this update faster?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.117908</guid>
	<pubDate>Fri, 27 Mar 2009 13:02:50 -0800</pubDate>
	<category>friday</category>
	<category>help</category>
	<category>Iwantoplayoutside</category>
	<category>mysql</category>
	<category>query</category>
	<category>sql</category>
	<category>stuck</category>
	<dc:creator>special-k</dc:creator>
	</item>
	<item>
	<title>Upsize Access database?</title>
	<link>http://ask.metafilter.com/116363/Upsize%2DAccess%2Ddatabase</link>	
	<description>I have been asked to make a proposal to upsize an Access database to allow for a few more concurrent users (currently 10) and ideally improve the overall performance of the system. Am I getting in over my head? To give an idea as to the size of the project the current system has 35 tables, and on the order of 1000 queries and 1500 macros defined. Not even the original developer (the client) knows which ones are actually in use. There are on the order of 200,000 records in the current live system. The client is not willing to spend the money to have the system completely re-built (which I would estimate at being at 3-6 months&#8217; work) but they would like some input as to how the current system could be improved, and they are probably willing to spend enough to cover two to three weeks of my time.&lt;br&gt;
&lt;br&gt;
I have done some tests, successfully upsizing the tables to MySQL, but even a single insert from one of the simpler entry forms fails. I figure that with my basic knowledge of SQL that I could probably get a lot of it working (if not very efficiently), but would MS SQL be a better bet for compatibility and performance issues? I have a fair amount of experience with Access, having built customer management and billing systems from scratch, but am no SQL/RDBMS guru. I could use this work, but am I doomed to fail?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.116363</guid>
	<pubDate>Tue, 10 Mar 2009 13:39:02 -0800</pubDate>
	<category>Access</category>
	<category>database</category>
	<category>MSSQL</category>
	<category>MySQL</category>
	<category>RDMBS</category>
	<category>SQL</category>
	<category>upsize</category>
	<dc:creator>cbrody</dc:creator>
	</item>
	<item>
	<title>Help me askme, you&apos;re my only hope.</title>
	<link>http://ask.metafilter.com/116271/Help%2Dme%2Daskme%2Dyoure%2Dmy%2Donly%2Dhope</link>	
	<description>I&apos;ve got an interview for a marketing analytics position that involves SQL - how can i learn about SQL/practice? I know the basics concepts of SQL (i.e. Select, by, where, join, etc) - but nothing about the actual use - I&apos;ve never used the program.  I understand SQL is a database language.  Is there a program most people use to run these databases and if so how is the data usually accessed?  I have a few days to learn this stuff and become a decent user.  What should I read?  How should I practice?&lt;br&gt;
&lt;br&gt;
They said they&apos;d like me to work both with &apos;raw data&apos; and &apos;through an interface&apos;.  What does this mean?  &lt;br&gt;
&lt;br&gt;
I&apos;m pretty computer savvy, but mostly with more basic applications, including Office, SPSS, and a few others, but I&apos;ve just never had to use SQL before.  I am decent at data analysis so I hope I can make this transition easily.  &lt;br&gt;
&lt;br&gt;
Throw watchu got at me.&lt;br&gt;
&lt;br&gt;
Thanks.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.116271</guid>
	<pubDate>Mon, 09 Mar 2009 17:02:37 -0800</pubDate>
	<category>dummies</category>
	<category>for</category>
	<category>SQL</category>
	<dc:creator>jourman2</dc:creator>
	</item>
	<item>
	<title>Will SQL 2000 work in 2008 domain?</title>
	<link>http://ask.metafilter.com/115196/Will%2DSQL%2D2000%2Dwork%2Din%2D2008%2Ddomain</link>	
	<description>Nerdlinger/Microsoft Server Filter: Can SQL 2000 exist in a Windows 2008 Domain when installed on a Windows 2000 member server ?

Before anyone says it, yes, yes I know it&apos;s old, outdated, unsupported, we should be using SQL 2005 or looking at SQL 2008  and that it can&apos;t be installed on a Windows 2008 server.

BUT... does anyone know if SQL 2000 will work when installed on a Windows 2000 server that is a member of a Windows 2008 domain?

I know that Windows 2000 servers can be members of a 2008 domain but Exchange 2000 won&apos;t work. Will SQL 2000?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.115196</guid>
	<pubDate>Wed, 25 Feb 2009 20:33:57 -0800</pubDate>
	<category>2000</category>
	<category>2008</category>
	<category>Server</category>
	<category>SQL</category>
	<category>Windows</category>
	<dc:creator>Man_in_staysis</dc:creator>
	</item>
	<item>
	<title>How do I e-mail reports based on Excel documents?</title>
	<link>http://ask.metafilter.com/114752/How%2Ddo%2DI%2Demail%2Dreports%2Dbased%2Don%2DExcel%2Ddocuments</link>	
	<description>Is there a nice way for me to run a report on an Excel spreadsheet and have that report e-mailed to me? I have a spreadsheet with dates of contracts expiring, I would like for it to shoot me an e-mail notifying me that I&apos;m within 30 days of that contract expiring, that a new contract has been added and so on. I&apos;m using Excel2007 and have access to a TechNet license so I can test and try before I buy. I have a spreadsheet I created that breaks down some complicated contracts where certain things happen at certain times. It would be really neat if it would remind me when certain events are about to happen, or when changes are made.&lt;br&gt;
&lt;br&gt;
Is this something SQL Server Express or one of the for-pay variants will do? If so can I use Excel to construct and work on the spreadsheets and then have SQL pick it up and do the backend stuff?&lt;br&gt;
&lt;br&gt;
There&apos;s nothing really complicated in the spreadsheets, they&apos;re all small (less than 100 rows) and unlinked. I know this has to be simple, that there&apos;s got to be something that will open the workbook, extract information out of cells and pass them onto my SMTP host.&lt;br&gt;
&lt;br&gt;
Preferably Microsoft centered solution as I might have to pass this off to intelligent but non-technical people in the future.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.114752</guid>
	<pubDate>Fri, 20 Feb 2009 15:50:20 -0800</pubDate>
	<category>email</category>
	<category>excel</category>
	<category>sql</category>
	<dc:creator>geoff.</dc:creator>
	</item>
	<item>
	<title>Help solve my SQL mystery</title>
	<link>http://ask.metafilter.com/114641/Help%2Dsolve%2Dmy%2DSQL%2Dmystery</link>	
	<description>How can I get the IN function to work in my SQL? There are two tables, CONTACT and QUEUE. CONTACT&apos;s columns are contactid and queuelist. QUEUE&apos;s columns are queueid and queuename.&lt;br&gt;
&lt;br&gt;
Example CONTACT record&lt;br&gt;
contactid = user1, queuelist = &apos;q1&apos;,&apos;q2&apos;&lt;br&gt;
&lt;br&gt;
Example QUEUE records&lt;br&gt;
queueid = q1, queuename = Queue1&lt;br&gt;
queueid = q2, queuename = Queue2&lt;br&gt;
queueid = q3, queuename = Queue3&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;SQL&lt;/strong&gt;&lt;br&gt;
SELECT queuename&lt;br&gt;
FROM QUEUE&lt;br&gt;
WHERE queueid IN&lt;br&gt;
(SELECT queuelist&lt;br&gt;
FROM CONTACT&lt;br&gt;
WHERE contactid = &apos;user1&apos;)&lt;br&gt;
&lt;br&gt;
except this SQL doesn&apos;t produce Queue1 and Queue2 as the expected output and I can&apos;t figure out why. If I simply replace the select statement in the brackets with &apos;q1&apos;,&apos;q2&apos; (the queuelist) it works.&lt;br&gt;
&lt;br&gt;
Is there something fundamental I&apos;m missing?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.114641</guid>
	<pubDate>Thu, 19 Feb 2009 11:32:42 -0800</pubDate>
	<category>infunction</category>
	<category>list</category>
	<category>Oracle</category>
	<category>resolved</category>
	<category>SQL</category>
	<dc:creator>urbanwhaleshark</dc:creator>
	</item>
	<item>
	<title>Can I specify the order in an ORDER BY clause in a SQL Statement?</title>
	<link>http://ask.metafilter.com/114625/Can%2DI%2Dspecify%2Dthe%2Dorder%2Din%2Dan%2DORDER%2DBY%2Dclause%2Din%2Da%2DSQL%2DStatement</link>	
	<description>Can I specify the order in an ORDER BY clause in a SQL Statement? If not then what is the best way of doing the following query? Can I specify the order in an ORDER BY clause in a SQL Statement so that it is neither ASC or DESC?&lt;br&gt;
or if I can&apos;t - which I think is the answer after searching in vain on Google -  then what is an alternative to solve this seemingly easy problem.&lt;br&gt;
&lt;br&gt;
Employee directory. Each employee is assigned to a department. Many but not all employees are assigned to a second department. The directory lists the employees by last name. &lt;br&gt;
&lt;br&gt;
What needs to happen is that if a department (say # 3) is queried, all persons who are assigned either primarily or secondarily to that department get listed, but the order must be by Primary department, lastname, THEN just lastname.&lt;br&gt;
&lt;br&gt;
Thus if a query is for department &lt;b&gt;3&lt;/b&gt; then the output must be&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DEPT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SECONDARY DEPT&lt;/b&gt;&lt;br&gt;
Johnson, J.  &lt;b&gt;3&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
Jones,M.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;3&lt;/b&gt;           &lt;br&gt;
Moss, P&amp;nbsp;.&amp;nbsp;&amp;nbsp;     &lt;b&gt;3&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
Adams, J.&amp;nbsp;    4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;3&lt;/b&gt;&lt;br&gt;
Johnson.Q&amp;nbsp;  1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;3&lt;/b&gt;    &lt;br&gt;
&lt;br&gt;
(note that it doesn&apos;t matter what department the secondary users are in, that can be sorted by just last name)&lt;br&gt;
&lt;br&gt;
The select statement I have is something like this;&lt;br&gt;
&lt;br&gt;
SELECT employee.id, employee.lname, employee.fname, employee.department, employee.secondarydepartment FROM EMPLOYEES WHERE (employees.department = &quot;3&quot; OR employees.secondarydepartment = &quot;3&quot; ORDER BY  *huh*? (this is where I am stuck.)&lt;br&gt;
&lt;br&gt;
Problem is there are at least six departments, each assigned a number, so using ORDER BY Department won&apos;t work if it is in the middle.  &lt;br&gt;
&lt;br&gt;
I am toying with the ideal of creating a second table, something like employeesaffiliation and then doing a JOIN, complicated, but I think I can do it - unless SQL experts can point me on the right path. I admit I am out of my league with more than simple queries.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.114625</guid>
	<pubDate>Thu, 19 Feb 2009 09:18:27 -0800</pubDate>
	<category>Databases</category>
	<category>Orderby</category>
	<category>resolved</category>
	<category>SQL</category>
	<dc:creator>xetere</dc:creator>
	</item>
	<item>
	<title>Help save me hours of busy work</title>
	<link>http://ask.metafilter.com/114356/Help%2Dsave%2Dme%2Dhours%2Dof%2Dbusy%2Dwork</link>	
	<description>How can I update whole columns in a sql database using new information from an excel spreadsheet while using a Mac? I&apos;m using Version 1.3 SQlite Database Browser to manipulate data in a .sql database. For three of the columns, I actually now need to change all values so that decimal point moves 2 places to the left. As of now, the only way I can seem to do this is one cell at a time, which will take forever (because there are 1800+ cells).&lt;br&gt;
&lt;br&gt;
(By the way, I&apos;m using the word &quot;column&quot; in the excel manner, as opposed to row - the information associated with each record.)&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://elanyarts.net/images/sql.tiff&quot;&gt;Here&apos;s an example&lt;/a&gt; of what I&apos;m talking about. How could I do a mass update to the LAT or the LONG, assuming I have the updated information in Mac OS Excel?&lt;br&gt;
&lt;br&gt;
Is there a way to be able to make mass updates (which I now have in an excel spreadsheet), using a Mac? I&apos;d be willing to download software for pay!</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.114356</guid>
	<pubDate>Mon, 16 Feb 2009 12:47:14 -0800</pubDate>
	<category>Mac</category>
	<category>resolved</category>
	<category>SQL</category>
	<dc:creator>visual mechanic</dc:creator>
	</item>
	
	</channel>
</rss>

