title: SQL Query to Display Two Values for a column?
body: <p>I am trying to write a SQL query that will display the store, ID, MAC and AppName for any device that contains the apps "iMobilePOS" and "StoreFulfill" in the AppName columns.  I am very very close...what I am trying to do is display only two lines for each of those devices.  One containing the "iMobile" AppName value, and the other containing the "StoreFill" AppName value.  Currently, the results are displaying a line for every single app the device has installed...here is my query for reference:</p>
  
  <pre><code>SELECT DISTINCT storenumber, 
                  registerid, 
                  wifi_mac, 
                  appname 
  FROM   mpos_health.dbo.mdat_data_report AS mdat 
         INNER JOIN mpos_health.dbo.mpos_health_report AS mpos 
                 ON mdat.wifi_mac = mpos.wifimac 
  WHERE  EXISTS (SELECT * 
                 FROM   mpos_health.dbo.mpos_health_report AS mpos 
                 WHERE  mpos.wifimac = mdat.wifi_mac 
                        AND appname = 'iMobilePOS') 
         AND EXISTS (SELECT * 
                     FROM   mpos_health.dbo.mpos_health_report AS mpos 
                     WHERE  mpos.wifimac = mdat.wifi_mac 
                            AND appname = 'StoreFulfill'); 
  </code></pre>
  
  <p>I am joining the two tables because they both have information I want to include, and their common value is the WiFiMAC of the device.  This query is filtering devices the way I would want, but it is including all applications.  For example, here is what I am seeing currently:</p>
  
  <p><a href="https://i.stack.imgur.com/xLqsd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xLqsd.jpg" alt="enter image description here"></a></p>
  
  <p>Where, I would not want to see the second line for MobileIron, I would only want to see the other two lines.  Containing iMobilePOS and StoreFulfill.</p>
  
  <p>Any suggestions are greatly appreciated.  Thank you very much.</p>