I have a DB which is an Attendance List for a Training Program. In this list - First Subscriptions gets Priority - and LOCAL USERS have priority too.
DB:
ID NAME SUBSCRIPTION DATE COUNTRY
1 JOHN 2018-04-05 12:00:00 USA
2 MARY 2018-04-05 12:30:00 CANADA
3 CARL 2018-04-05 13:00:00 USA
I need a way to order the table like this:
ID NAME SUBSCRIPTION DATE COUNTRY
1 JOHN 2018-04-05 12:00:00 USA
3 CARL 2018-04-05 13:00:00 USA
2 MARY 2018-04-05 12:30:00 CANADA
CARL is from USA then I need to give priority to him, even Mary makes his subscription early.
any idea?
** IMPORTANT: Country priority changes according to the location of the training. (here the location is "USA", but can be any country)
I tried this:
SELECT * FROM SUBSCRIPTION_TABLE ORDER BY COUNTRY = 'LOCAL_COUNTRY_VAR', SUBSCRIPTION_DATE
but it did not work.
You appear to want to order first by being in the USA and then by the date:
In MySQL, you can do:
order by (country = 'USA') desc, date
I would recommend creating a separate table with the location and a priority code (integer). Inner join the two and then order by the priority code ascending. USA would have priority 1, CANADA would be 2.
First time Poster here so I appoligize about the formatting and am really novice at sql, but this has me stumped. That and I am using 2016 MS Access's SQL as well.
I have a table and I want to select only the names of the people who have fulfilled all the requirements.
Table Chore
ID Name Chore Done
1 Joe Sweep Yes
2 Joe Cook Yes
3 Joe Dust Yes
4 Bill Vacuum No
5 Bill Dust Yes
6 Carrie Bathroom Yes
7 John Cook No
8 John Beds No
9 John Laundry Yes
10 Mary Laundry No
11 Mary Sweep No
12 Cindy Car Yes
13 Cindy Garden Yes
In this case, only Joe, Carrie and Cindy's names should be returned because under their name, they finished all their chores.
Help please and thanks in advance!
You can use not in
select name from my_table
where name not in (select name from my_table where chore_done ='No');
You could check the value of max(done), like
select
name
from
my_table
group by name
having max(done) = -1
In Access, Yes/True is -1, No/False is 0, so max(done) is Yes
I am working on employee attrition analysis with a table having rowwise data for a (employee like Id, name, Date_Join Date_Relieving Dept Role etc)
eID eName Joining Releiving Dept Married Experience
123 John Doe 10Oct15 12Oct16 HR No 12
234 Jen Doee 01jan16 -NA- HR No 11 (ie she is available)
I can run regression on this data to find the beta coefficient
eID eName Joining Releiving Dept Married Experience
123 John Doe 10Oct15 12Oct16 HR No 12
234 Jen Doee 01jan16 -NA- HR No 11
But I've seen other approach too.. where employee have multiple entries depending on their difference between joining date and current month or relieving month(say Employee A joined in Jan and Left in Dec so he'll have 12 entries updating corresponding columns like experience and marriage etc)
eID eName Dept Married Experience
123 John Doe HR No 0
123 John Doe HR No 1
123 John Doe HR Yes 2
123 John Doe HR Yes 3
can someone tell what differentiate two approaches.. and what is the outcome of this second approach.
In Oracle you can SELECT data from a table and request interactive user input to be used in the WHERE condition. This is done by specifying &column in the WHERE statement and user input will be prompted and used in its place. For example:
SELECT Ename, Deptno, Job, Sal FROM Emp
WHERE Sal &GiveNegationState BETWEEN 1100 AND 2850
SQL> /
Enter value for givenegationstate: NOT
ENAME DEPTNO JOB SAL
---------- ---------- --------- ----------
KING 10 PRESIDENT 5000
JONES 20 MANAGER 2975
JAMES 30 CLERK 950
FORD 20 ANALYST 3000
SMITH 20 CLERK 800
SCOTT 20 ANALYST 3000
Can this be done in MySQL?
I am trying to create an Employee Utilization report in SSRS (Visual Studio 2010, SQL Server 2012)
We have employees who work for multiple program managers. I need a report that shows program managers, the employees who work for them, and the utilization of each employee by each manager they work for. This will allow us to identify which employees do not have their utilization distributed correctly.
The dataset query returns data such as:
EmpID Emp Mgr Util Total Util
1234 Doe, John Lundy, Sal 100 100
2345 Ward, Joe Lundy, Sal 40 110
3456 Kline, Rob Smith, Bob 100 100
4567 Abbott, Fred Smith Bob 100 100
2345 Ward, Joe Smith, Bob 70 110
The results, when grouped by manager, should look like this (with the plus indicating the expand toggle):
Mgr Emp UtilMgr Util Total Util
Lundy, Sal
+Doe, John 100
+Ward, Joe 110
Smith, Bob
+Kline, Rob 100
+Abbott, Fred 100
+Ward, Joe 110
When an employee is expanded, the detail will show the employee utilization broken down by the different program managers they do work for:
Mgr Emp UtilMgr Util Total Util
Lundy, Sal
-Doe, John 100
Lundy, Sal 100
-Ward, Joe 110
Lundy, Sal 40
Smith, Bob 70
Smith, Bob
+Kline, Rob 100
+Abbott, Fred 100
+Ward, Joe 110
I have tried all kinds of grouping and property combinations (parents, children, display detail) in the report, but cannot get the results to be grouped the way I want it. I tried adding another manager field (aliased as UtilMgr) to the query, but still couldn't get the report correct.
I'm looking for the best way to handle this. It seems like the solution is to have the Program Manager as a parent to the Employee, and then have a second group where the Employee is a parent to the Manager, but I'm not sure how to implement that.
Do I need to do something different with the query? Do I need to use a subreport or a second matrix, nested in the first? Is there some way to create overlapping parent/child groups?
I have only been working with SSRS for about 2 weeks, so I hope all the terminology I've used is clear and correct. Thanks in advance for any help!
Can you change your query?
In order to do what you want, your dataset needs to look like this:
EmpID Emp Mgr UtilMgr Util Total Util
1234 Doe, John Lundy, Sal Lundy, Sal 100 100
2345 Ward, Joe Lundy, Sal Lundy, Sal 40 110
2345 Ward, Joe Lundy, Sal Smith, Bob 70 110
3456 Kline, Rob Smith, Bob Smith, Bob 100 100
4567 Abbott, Fred Smith, Bob Smith, Bob 100 100
2345 Ward, Joe Smith, Bob Smith, Bob 70 110
2345 Ward, Joe Smith, Bob Lundy, Sal 40 110