I have surveys that I need to add weights to and was wondering if there was a way to convert the contents of a column.
select empid, ans_for_ql,
(if ans_for_ql = A then 0, B then 3, C then 5) as weightscore,
ans_for_q2,
(if ans_for_q2 = A then 8, B then 4, C then 2, D then 1, E then 0) as weightscore
Here is what the table looks like:
empid | Ans_for_Q1 | Ans_for_Q2
1001 A C
1002 B E
And these are the possible answers and what they need to be converted to:
Weights for answers to Question1
Q1_A = 0
Q1_B = 3
Q1_C = 5
Weights for answers to Question2
Q2_A = 8
Q2_B = 4
Q2_C = 2
Q2_D = 1
Q2_E = 0
I am trying to interpret some of the results I observe when trying to match similar records using a fuzzy lookup transform, but it's not entirely clear how the overall row similarity score is calculated. In particular, sometimes rows with lower individual column similarity scores will achieve a higher similarity and confidence score than a matching row with higher individual column scores.
The transform is configured with 6 text fields set to fuzzy mapping and a minimum similarity of 0, and 3 additional numeric fields with an exact mapping. It is set to return a maximum of 2 matches per lookup and to do an exhaustive search of the reference table.
For example, from the following matching pair of records Match 1 is picked over Match 2 even though it's individual scores are lower.
SQL Server Integration Services team would like to hear from you. Our goal is to understand your current Data Extract, Transform & Load (ETL) practices and prioritize features for future releases.
You will have a chance to win one of five 80GB Zunes. To win a Zune, you must fill out the survey by Dec. 20, 2007.
To participate in the survey, please click here: https://mscuillume.smdisp.net/Collector/Survey.ashx?Name=SqlETLSurvey2
I have a database that holds student details in one table and their scores in particular subjects in another. The tables are linked through ID. The subjects table looks like this. (example)
I am trying to build a query where I want to extract the sum of the scores for each code MCC and get the percentage over the sum of all the scores over the last 90 days
select MCC, sum(score) as total from scores (select Datediff(day, creationdate, getdate()) as Q from scores where Datediff(day, creationdate, getdate()) <90) group by MCC
I am stumped on a set-based approach for this one.
A cursor approach is straightforward enough, but i want to avoid that.
Here's my table:
create table StudentScores ( id int primary key identity(1,1), student_id int not null, score int not null )
with some sample data:
insert into StudentScores (student_id, score) select 1, 10 union all select 1, 29 union all select 1, 50 union all select 1, 53 union all select 1, 45 union all select 1, 10 union all select 1, 29 union all select 1, 50 union all select 1, 53 union all select 1, 45 union all select 1, 88 union all select 2, 23 union all select 2, 54 union all select 2, 55 union all select 2, 34 union all select 2, 56 union all select 2, 78 union all select 2, 23 union all select 2, 54 union all select 2, 55 union all select 2, 34 union all select 2, 56 union all select 2, 78 union all select 2, 23 union all select 2, 54 union all select 2, 55 union all select 2, 34 union all select 2, 56 union all select 2, 78 union all select 2, 98
What I want is, for each student, what is their 90th percentile score?
For a given single student, one possibility would be:
declare @studentid int set @studentid = 2 select top 1 @studentid as student_id, a.score as [90th percentile score] from ( select top 90 percent score from StudentScores where student_id = @studentid order by score asc ) as a order by a.score desc
But I want this for all students, and not use a cursor.
I have a table and am usuing ASP to query the database, the connection is to a MS Access table at the moment but am working to convert to SQL Server.
Question:
I need to select the last 20 records, by a date field, then from those 20 records select the 10 lowest scores.
Example is a member logs on an that member has say 80 total records in the table. Then I need to select the last 20 records entered by the date field then select the lowest 10 scores out of those 20.
I am new to more compex SQL Statements any help would be mostly appreciated!
table = HC_ID date field = date member_id = member score = ScoreHC
I am trying to modify a survey DB schema created by OOP(Object Oriented Programming) snobs who had their heads so far up their butts(in my opinion). This is current schema created by them.
Actually there aren't a several foreign keys as they are shown in the picture, but that's what they(OOP snobs) are doing to the table "Response". They are inserting question_collection_id and its name as well as question_id and its name to Response table. However, it was not ill-intended, "We just wanted to load the report quickly"(OOP snobs). But I really recommend this schema, Because of its simplicity.
Yet I haven't proven that my schema will provide report just as quickly as OOP snobs' version. As mentioned earlier, since they don't have foreign key constraints accordingly, I do find quite number of discrepancy on values of "question" columns between "Question" and "Response" tables and "question_collection" columns between "question_collection" and "Response" table. I can provide schedule task to eliminate those problems. But I really prefer my schema than theirs. So far, I can explain mine is better just because of its simplicity and DBA's gut instinct. I'd like to hear Superior Expert's opinion which schema is better and why one is better than the other.
Attached is also zip files of schema images if you can't see them by those URL.
The BI Survey is the largest independent survey of BI technology users worldwide. (It used to be known as the OLAP survey, but has expanded to cover a broader array of BI technologies.) The survey analyzes people's buying decisions, BI implementation cycles and business results achieved.
The BI Survey is strictly independent --- they ask vendors like us to ask our customers like you to participate, but we don't have any other involvement --- except closely reading the results, of course. The Survey will send all participants a summary of the full survey results and place them in a drawing for ten $50 Amazon vouchers.
You can complete the survey on-line by following these links:
English version - website: http://www.eu-survey.com/webprod/cgi-bin/askiaext.dll?Action=StartSurvey&T1=BI&lan=1&lin=20
German version: http://www.eu-survey.com/webprod/cgi-bin/askiaext.dll?Action=StartSurvey&T1=BI&lan=2&lin=67
I am going into salary negotiationyearly review next month after my week off and I am trying to determine what to ask for. I am thinking another 10K and an extra week off would not be unreasonable, but I wanted to get some idea of what you guys think I should ask for in terms of pay.I have been developing software for seven years and I have been a dba for a little over five. I live in pricey northern Virginia. On a fairly regular basis I do about 55 to 60 hour weeks. On my DBA team, I am the only one who can handle both development and production tasks. The others are strictly developers. Although I have been relieved of most of my customer support tasks by our newbie, the customer support manager still brings the nastier bits to me. It is my perception that the more complex tasks get assigned to me. I get told on a regular basis that I am the best dba this place has ever had and other embarrassing accolades are regularly thrown my way. After a year, other than my boss I am the dba that has been here the longest in high turnover high burnout company. This year as we try to move to a SAP model, it looks like we will be going to 24/7 support on a disaster recovery model I am designing and implementing, so I guess I am getting the pager.So how much money should I be asking for?you can PM me with a number if you want.
from (select distinct(clientID) ,sum(case when QuestionID = 1 and Answer in (1,2,3,4,5,6,7,8,9,10) then Answer else 0 end) as Q1_1 ,sum(case when QuestionID = 1 and Answer in (1,2,3,4,5,6,7,8,9,10) then Answer else 0 end) as Q1_2 ,sum(case when QuestionID = 1 and Answer in (1,2,3,4,5,6,7,8,9,10) then Answer else 0 end) as Q1_3 ,sum(case when QuestionID = 1 and Answer in (1,2,3,4,5,6,7,8,9,10) then Answer else 0 end) as Q1_4
from dbo.survey
group by clientid) as x
group by x.clientID ,x.Q1_1 ,x.Q1_2 ,x.Q1_3 ,x.Q1_4
Hi,We are a systems research group at the Computer Science departmentatRutgers University, and are conducting a survey to understand detailsabout network, systems and database administration. We hope that thisinformation would help us recreate a realistic environment to helpresearch in 'systems management'.We request network, systems, and database administrators to take thissurvey. As an incentive, all surveys completed in their entirety willbeentered into a drawing of a number of $50 gift certificates (fromAmazon.com).We hope you have a few minutes to take the survey which is located at:http://vivo.cs.rutgers.edu/administration_survey.htmlResearch in our group:The goal of our research is to improve the overall availability andmaintainability of services. Since administrators form an integral partof these services, a key aspect of this work is to build environmentsand tools that ease the task of service administration. In particular,environments which would help administrators know how their actionsmight impact the real service (before performing them for real), webelieve would be useful in preventing inadvertent actions. This surveytries to understand the existing environments, what administrators docurrently to test the 'validity' of their actions, and the difficultiesthey face in doing so. The two specific systems we are looking at arenetworks and databases, as we believe these are important components ofmany services.If you have any questions regarding this survey or our work, feel freeto email us:Fabio Oliveira (fabiool at cs || rutgers || edu), orKiran Nagaraja (knagaraj at cs || rutgers || edu)Thanks for your time,Fabio OliveiraPhD student, Vivo Research Group (http://vivo.cs.rutgers.edu)Rutgers University
Dear Madam/Sir,You are invited to participate in an international research study. Thisresearch project is headed and led by Cambridge student Nico Baumgarten.What is it all about?It is a well-known fact that there exist many differences between cultures.However, how these differences effect motivation if there are effects atall is not yet clear. This survey is set out to change this. With yourhelp, it will be possible to achieve this.Therefore, we kindly ask you to spare only 10 minutes of your time andvisit the survey home page.Go to the survey http://crosscultural.research.yi.orgor if this does not work the direct link http://82.4.146.32Who participates?All over the world, people are chosen to participate in the survey.Although the survey is completely anonymous, each person is arepresentative of his/her country. Hence, it does not matter, which job aperson has, whether he/she is male or female, old or young. The more peoplechoose to participate the more accurate this survey is going to representand show cultural influences as well as similarities.So if you want to tell your friends about this survey - Please Do So! Justforward this email to your friends or use the feature on the survey homepage.What is in it for you?With your help your country will be represented in the survey.Of course, you can opt-in to receive the results of the study at the end ofthe survey.Any information you provide will be kept strictly confidential andanonymous.Thanking you in advance for you support I remain withKind regardsNico Baumgartenhttp://crosscultural.research.yi.orghttp://82.4.146.32
I am a developer and I have a problem trying to design a system tomanage data coming from web surveys. Each section can potentially havedozens of questions, i.e., fields.I am focusing here only on the table(s) that will hold the survey data.I do not have any DDL as I am still trying to understand this!All the examples I have found so far in books and on the web seem todeal with fairly limited data, that is easily, or so it looks, brokendown in multiple tables.It seems that, from my research, having a wide table per survey sectionwith each field as a column, which has been suggested to me, is notproper design for many reasons - missing values for non-requiredquestions, table with 100s of possible columns, etc... - so I playedwith the idea of a single table where one of the columns would be theforeign key pointing to a questions table and another column would holdthe data (this is a simplified explanation.)The problem with this is that now this column will have to accomodateall types of data, from bits to large varchars, and that fieldvalidation seems now impossible jeopardizing data integrity.What do knowledgeable designers come up with in this case? Can someonepoint me in the right direction?Jerry
I've written several survey systems in which the majority of the questionshave the same or similar responses (Yes/No, True/False, scale of 1 - 5,etc).But this latest survey system I'm working on has 8-10 sections, with avariety of question attributes and answer scales. Some items have just adescription and require a Yes/No answer, others have a description and anactive status and require a Yes/No and price answer, some require a comment,etc.Rather than build a separate response table for each survey section, I wasthinking of building one generic response table, and trying to force allsections to fit by adding columns - some of which won't apply to some items.Like this:Survey Category (will apply to all items)Survey Section (will apply to all items)Item Description (will apply to all items)Item YN (will apply to all items)Item Price (will apply to about 10% of the items)Item Points (will apply to about 10% of the items)Item Active YN (will apply to about 10% of the items)Item Fail YN (will apply to about 10% of the items)Item Comment (will apply to about 10% of the items)For instance, in the structure above the field "Item YN" would representmultiple types of answers: is the item in use?, is the item in place?, isthe item given away for free?, is the item on display?, etc. Basically,anywhere a Yes/No answer is used.The advantage is one source table (rather than 8) for storing answers, andit might be easier to query and report on.The disadvantages I see are 1) it's more difficult to understand the meaningof the responses when the answer field is named Item YN, and 2) you have anon-normalized table that's difficult for a 3rd party to understand.If I have the questions and responses in separate tables, I'll use nameslike "ItemComplimentaryYN" and "ItemUsedYN" depending on the question. It'seasier for others to learn the data.I actually don't like the "generic" approach, and probably won't use it, butI figured I'd try to get some input from others who've written surveysystems.Thanks
Dear friendsI am conducting a survey on Relational Database usage and would likeyour help. The study is part of my MBA Dissertation.Could you kindly spare 5 minutes to take part in this survey?http://FreeOnlineSurveys.com/rendersurvey.asp?id=120816ThanksRajeev
I am working on a survey system with another DB Engineer.Our current design includes 1 table per Question Type (Numeric, Boolean, Text), Response values are tightly coupled based on data being entered, to keep things simple assume there are only 6 tables in this this system (1 for each Question Type to define the "rules" of the data entered, and 1 for each Response collection).He is a former .Net programmer and has been talking with the .Net guys on the project and he is proposing that we abstract our Question Types to use one table and store the Input Values all as nvarchar(max).This obviously simplifies the DB design and reduces the amount of work I will need to do so I should be all for it. I guess I am a little concerned that we are no longer tightly coupling the data types and essentially leaving all the validation up to the application. Also should I be worried that a bunch of bit data will be stored as 1/0 in an nvarchar(max) column?Thanks,-John
Several prominent researchers are conducting a survey and looking for500 respondents by Friday on the topic of enterprise architecture andsoftware development. Here is the link to the survey:http://www.surveymonkey.com/s.asp?u=845572436515After completing the survey, results are displayed immediately. A smalldonation will be made to a charitable organization after itscompletion.http://duckdown.blogspot.com/
I am a developer and I have a problem trying to design a system to manage data coming from web surveys. On average each subject will take part in more than one survey and each survey may potentially have 100+ questions.
I am focusing here only on the table(s) that will hold the survey data.
I'm thinking about having a wide table storing each question in the survey(s) as a column against the subjects. My main concerns with this approach:
- the "yuckiness" and potentially other performance issues(?) associated with a table with 100s of columns - the 8kb size limit per row (unlikely to touch it, but possible) - 1024 column limit (unlikely to touch it, but possible)
Another approach obviously is to have a single table where we have, in a simplified version, 3 columns: person_id, question_id and data/ answer. The problem with this is that the "data" column will have to accommodate all types of data, from bits to varchars, and that field validation seems now impossible jeopardizing data integrity, and most importantly, you can't easily work with the data in filtering/ reporting etc.
What do knowledgeable designers come up with in this case? Can someone point me in the right direction?
- Sales Volume: Information about sold articles to a customer incl. Selling date - Survey: irregular answered survey questions about customers incl. date of answer and three Dimensions: - Customer - Date - Survey Answer: Information about possible Answer values (e.g. Yes / No)
We would like to be able to determine the aggregated sales volume (sum) of a customer for a specific period depending on the latest survey answer within this period.
For example: Selected Time period: Jan - Jul 2015 Sales Volume Customer X - Jan - Jul 2015: 1000 Litres Sales Volume Customer Y - Jan - Jul 2015: 500 Litres
Surveys answered:
15th Jan 15: Customer X, Survey Question A: Yes 2nd Mar 15: Customer X, Survey Question A: No 20th Apr 15: Customer X, Survey Question A: Yes
10th Feb 15: Customer Y, Survey Question A: Yes 20th Jul 15: Customer Y, Survey Question A: No
Latest survey answer (Jan-Jul) Customer X, Question A: Yes Latest survey answer (Jan-Jul) Customer Y, Question A: No
Excel Pivot should show something like this:
Question | Latest Answer: Yes | No |
------------------------------------------------------------------------------------ A | 1000 Litres | 500 Litres |
I want to sum up a column, but only summing up the top 25 quantites and then I want to subtract the sum of all quantities from the total of the top 25...how would this be done with t-sql?
Hi, What the best way to calculate the age given two datetimes. I tried using the DATEDIFF(yyy,startdate,enddate) but that seems to only compare the year and not look at the specific day.
I am looking for something that would return the following output
birthday= 12/6/1973 EndDate = 11/30/2001 then the age should be 27
If birthday = 12/6/1973 enddate = 12/11/1973 then the age should be 28
I'm in the process of developing a Kimball-method CRM data warehouse and I'd like to have Recency, Frequency, Monetary "scores" at the customer level. Am I better off creating these in the relational database and feeding them to SSAS or have SSAS do the aggregations and assign the "scores"?
Also, has anyone located any SSIS transform scripts that would calculated RFM scores? This is probably a pretty easy task in VB.net but I haven't gone down that road yet.
When users register with my site they give me their DoB, how can I work out an age from it. I was thinkin about doing it from the year, but that isnt very accurate. Can anyone help? thanks si! ps Id only want to work out how many years old they are. si!
I needed to come up with an algorithm to create unique user- friendly account numbers such as AC0000000001, AC0000000002, etc...Where they increment by 1. I created a SQL function that retrieves the previous number generated, adds 1 to it, inserts the new value into the table, then returns the new value. I started thinking, what if the function is ran at the same time? What if function # 1 creates the new number, and function #2 creates a new number as well before function #1 inserts it? Is this a possible scenario? If so, how do I lock the process until the function completes to prevent this? Thanks for any help you provide.
Hi, First off, let me state that i am new to ASP.net... and have had to hit the ground running... I have looked on the net but have not found a suitable explanation on how to do this. Let me explain what i am trying to do: In my aspx page, i have 2 dropdown boxes where the user will select a skill catagory, and then a skill. Based on that selection, i would like to compute what the Service line will be. There is a primary and foreign key on CatID on the skills and SkillCat tables. This data would need to be inserted into the another table aswell, and this would need to go into a report later. How do i go about doing this? Some examples would be greatly appreciated. And if you know of a good link, please post it for me. Skills Table
I'm fairly new to MS SQL, but I'm trying to query the time elapse between two dates. Example below...
Select dbo.res.book_date, dbo.res.arrive_date, Cast (dbo.translog.systemdate as datetime) From dbo.res Where dbo.res.resid > '500'
The third line is where I need help with a statement. I need the elapse time. Ex. if the book date is 20050820100000 and the arrive date is 20050820120000, I would like the third Select statement to return 2:00 hours or something similar. Thanks.