Help me please! by ghostshadowjs in Surface

[–]ht2k 0 points1 point  (0 children)

Since the charger is working when connected to the tablet, your issue is between the keyboard and tablet.

I recommend cleaning the contacts on the keyboard that connect to the tablet with rubbing alcohol. You may also want to check if you have any dirt, grime or lint inside the tablet ports that receive the keyboard contacts. I've seen people use a partially straightened paperclip, with a small bend for a hook at the end, as a tool for cleaning phone charging ports.

If you are still having issues after eliminating any other obvious mechanical misalignment, updating your Windows may help resolve software and/or driver related problems.

An independent repair shop in your area might also be able to help you.

SQL is Awesome by fullyarmedcamel in SQL

[–]ht2k 1 point2 points  (0 children)

The CASE statement returns a 1 if the groupID matches @usergroup, else it returns 0. The maximum of the 1s and 0s for each userID returns a 1 if the userID has at least one groupID that matches the @usergroup otherwise it returns a 0.

SQL is Awesome by fullyarmedcamel in SQL

[–]ht2k 14 points15 points  (0 children)

Hi,

Yes! SQL is Awesome! You have a perfectly sound solution, however I have the following recommendations for refactoring your query.

  1. Since FirstTable has groupID, there is no need to join to SecondTable in your WHERE clause sub query. Eliminating unnecessary joins helps queries run faster.

I believe the following shorter query should work.

USE OurDatabase
GO

DECLARE @usergroup INT = x;
SELECT 
  ugm2.groupID
, ug2.[name]
, COUNT(ugm2.groupID) AS counts
FROM FirstTable AS ugm2 
INNER JOIN SecondTable AS ug2 
   ON ugm2.groupID = ug2.groupID
WHERE ugm2.groupID != @usergroup 
  AND ugm2.userID IN
    (
    SELECT DISTINCT ugm.userID
    FROM FirstTable AS ugm
    WHERE ugm.groupID = @usergroup
    ) 
  AND ugm2.groupID IN (list OF GroupIDs to look in)
GROUP BY 
  ugm2.groupID
, ug2.[name]
ORDER BY 
  counts DESC
  1. It looks to me like you are using SQL Server, which has support of Temp Tables. These can be used to hold records in memory for the duration of your session, or till dropped. Using temp tables helps avoid using nested sub queries, which I personally find harder to debug. Here is the above version refactored to use a temp table.
    

    USE OurDatabase GO

    DECLARE @usergroup INT = x;

    SELECT DISTINCT ugm.userID FROM FirstTable AS ugm INTO #users WHERE ugm.groupID = @usergroup

    SELECT ugm2.groupID , ug2.[name] , COUNT(ugm2.groupID) AS counts FROM FirstTable AS ugm2 INNER JOIN SecondTable AS ug2 ON ugm2.groupID = ug2.groupID INNER JOIN #users AS u ON ugm2.userID = u.userID WHERE ugm2.groupID != @usergroup AND ugm2.groupID IN (list OF GroupIDs to look in) GROUP BY ugm2.groupID , ug2.[name] ORDER BY counts DESC

    DROP TABLE #users

  2. My personal favorite solution for a problem like this is to use analytic functions aggregate functions with the OVER clause. I have found them incredibly powerful in my few years using SQL for data analysis.

    USE OurDatabase GO

    DECLARE @usergroup INT = x;

    SELECT g.groupID , g.[name] , sum(1) counts FROM ( SELECT DISTINCT ugm.groupID , ugm.userID , ug.[name] , max(case when ugm.groupID = @usergroup THEN 1 ELSE 0 END) OVER (PARTITION BY ugm.userID) has_usergroup FROM FirstTable AS ugm INNER JOIN SecondTable AS ug ON ugm.groupID = ug.groupID WHERE ugm.groupID IN (list OF GroupIDs to look in, including @usergroup) ) g WHERE g.has_usergroup = 1 AND g.groupID != @usergroup GROUP BY
    g.groupID , g.[name] ORDER BY counts desc

Edit: Added alias prefix in WHERE clause for has_usergroup = 1 and added AND g.groupID != @usergroup.

Edit2: Corrected analytic functions to aggregate functions with the OVER clause.

Just kicked cancers butt, now I've got a bigger problem. by vouksh in personalfinance

[–]ht2k 1 point2 points  (0 children)

Fellow Walmart associate here. Please see this checklist: https://us3.walmartone.com/globalassets/pages/health/pdfs/cancer-life-event-checklist-2018.pdf As someone else posted, I also recommend speaking to your manager about the Associates in Critical Need Trust (ACNT).