Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a table A having name of people and Table B having name of people and their membership with different organization. Is there any way I can get the total number of membership of each and every people using count function or any way?
Is there any way I can get the total number of membership of each and every people using count function or any way?
Did you try a Pivot? See screenshot below
I have taken a scenario as you mentioned in Andy G's post... with multiple memberships...
You haven't explained how SQL is involved, but if the two tables are both in Excel then you only need to count the number of times each name occurs in the second table, using COUNTIF and copying this formula down the column:
I'm assuming their membership of an organization is not repeated in the 2nd table.
Added It is more complicated knowing that the combination of person and organization repeats in the second table, but it can be done with an array formula. Use Ctrl-Shift-Enter to complete the following formula, then copy it down the column.
=SUM(IF($E$2:$E$13=A2, 1/(COUNTIFS($E$2:$E$13, A2, $F$2:$F$13, $F$2:$F$13))))
I cannot claim origination for this, a colleague of mine Rudi completed it for me.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
How does one get the first name info from a Users table, which has a first name column?
First of all welcome to the community. I suggest you read the guidelines on how to properly ask a question here and you might want to write a title that is relevant to your question.
Now to the question:
Assuming tblUsers is a table in your database and 'first_name' is a column in your table, you can use SELECT followed by the column you want to select.
Lastly, add FROM to select which table you want to select from.
So in your case it would be:
SELECT first_name FROM tblUsers;
You can read more about SELECT here
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I'm trying to clone a table schema and data into a new table, this is what I'm doing:
SELECT * INTO 'ECO7053__settings' FROM base__settings
I keep getting the Undeclared Variable error
EDIT: Also to complete the questions, is this the correct approach? I need to store data for different users; is it better to add an uID field on my tables and filter by that or rather what I'm trying to do, and have different tables one for each user with a prefix? In the example the uID would be 7053 what would be the correct way to handle this situation?
CREATE TABLE ECO7053__settings LIKE base__settings;
to copy the table schema and indices. Then
INSERT INTO ECO7053__settings SELECT * FROM base__settings;
to copy the data.
Use:
SHOW CREATE TABLE base__settings
Copy the create statement and change base__settings into ECO7053__settings (do a search and replace)
Then run
INSERT INTO ECO7053__settings
SELECT * FROM base__settings
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have found out a lot of messages from stack overflow but it is too much information to me , and I didn't see any clear code ,I wish I can use like as below URLs with easy way
Querying data by joining two tables in two database on different servers
Selecting data from two different servers in SQL Server
PS: sorry for all , maybe my English isn't very well ,so that I cannot understand or know , hopefully someone can give me a very simple code
This sample is very easy , hopefully it is you want
1.Data Source <=Server ip or ServerName
2.Initial Catalog <= DB Name
3.User ID <= Account ID
4.Password <= Account PWD
5.[*****].[dbo].[awards] <= which table you want to find out
SELECT *
FROM OPENDATASOURCE('SQLNCLI',
'Data Source=10.***.***.***;Initial Catalog=B2C**;User ID=****;Password="****"')
.[*****].[dbo].[awards]
PS: more detail you can see
https://msdn.microsoft.com/zh-tw/library/ms179856(v=sql.120).aspx
or Querying data by joining two tables in two database on different servers
or Selecting data from two different servers in SQL Server
it will be gave you more detail ways or methods
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am trying to help a friend who wants to set uo a MLM organisation. He needs to calculate income for everyone he will enroll.
The issue is that a top-level employee gets his own commission PLUS a percentage of everyone's commission he has enrolled...
[Do]
...these guys in turn get their own commission PLUS also a percentage of everyone's commission that they have enrolled, and this additional commission also has an upstream effect on the top level guy's percentage (this goes all the way down the line)...
[Loop]
potentially, this goes on ad-infinitum. So I can't calculate the upstream commission until I have calculated the commission right down to the bottom, but there may be hundreds of levels.
In the data I'm looking at, I know everybody's sales and I know the ID no. of the person who has enrolled them, I don't necessarily know how far down a chain they are.
How can I model this for him? I can't get my head round it.
Has anyone else ever had to work this out? Am I missing something obvious?
Thanks
You have typo error in following formula:
=SUMIFS([Upstream commision - outgoing],[Parent ID],[ID])
shoud read
=SUMIFS([Upstream commission outgoing],[Parent ID],[ID])
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
CREATE TRIGGER noOfBooks
AFTER INSERT ON BooKLoan
FOR EACH ROW
BEGIN
UPDATE Book SET noOfLoan=noOfLoans + 1
WHERE Bookloan.bookTitle= :new.bookTitle;
END;
/
(adding one to the noOfLoans column for a book title in table Book, after each time that book title is entered into a new loan row in table BookLoan)
Can anyone help me to the solution please ?
Making some wild assumptions here that you want to increment Book.noOfLoans every time an associated BookLoan record is inserted, There are at least 2 issues in your code:
UPDATE Book
SET noOfLoan=noOfLoan + 1
WHERE Book.bookTitle = :new.bookTitle;
noOfLoan or noOfLoans but not both
Since the trigger is on Bookloan, and it seems you want to update Book, you'll need to filter on Book.bookTitle, not Bookloan (since the new pseudo row is already a Bookloan row)