Categories
Database Development

Age Field, Get the Ages and Count by Age

I found this SQL and was trying to modify to fit my needs. It works well, but, I would like for the code to get the "[Person_Age]" then count, where the Case Statement is not needed for all the age ranges I will have, somewhere between 20-75: WITH AgeData as ( SELECT [Person_Age] –[Birthdate], — […]

Categories
Database Development

Age Field, Get the Ages and Count by Age

I found this SQL and was trying to modify to fit my needs. It works well, but, I would like for the code to get the "[Person_Age]" then count, where the Case Statement is not needed for all the age ranges I will have, somewhere between 20-75: WITH AgeData as ( SELECT [Person_Age] –[Birthdate], — […]

Categories
Database Development

Age Field, Get the Ages and Count by Age

I found this SQL and was trying to modify to fit my needs. It works well, but, I would like for the code to get the "[Person_Age]" then count, where the Case Statement is not needed for all the age ranges I will have, somewhere between 20-75: WITH AgeData as ( SELECT [Person_Age] –[Birthdate], — […]

Categories
Mastering Development

Convert float to varchar with IIF

I have query to convert float to varchar and its not working right. select (CONVERT (VARCHAR(50), age,128)) iif(Age = ‘0’,’under 1 year’, age) from student I cannot get it right.

Categories
Mastering Development

How do i join 4 tables in sql

Hi there I am a beginner in SQL coding and recently got an assignment from my teacher that I am not too sure how to do. If someone could help me by explaining what to do and how to do it. The assignment is: As we have found the limitation of the 3 table system […]

Categories
Linux Mastering Development

using awk how can i make row so i need to have 14-0273 under ID so making different columns for different stuff

ID,Date,DateType,Age,Sex,Race,ResidenceCity,ResidenceCounty,ResidenceState,DeathCity,DeathCounty,Location,LocationifOther,DescriptionofInjury,InjuryPlace,InjuryCity,InjuryCounty,InjuryState,COD,OtherSignifican,Heroin,Cocaine,Fentanyl,FentanylAnalogue,Oxycodone,Oxymorphone,Ethanol,Hydrocodone,Benzodiazepine,Methadone,Amphet,Tramad,Morphine_NotHeroin,Hydromorphone,Other,OpiateNOS,AnyOpioid,MannerofDeath,DeathCityGeo,ResidenceCityGeo,InjuryCityGeo 14-0273,06/28/2014 12:00:00 AM,DateReported,,,,,,,,,,,substance,,,,,"Acute fent, hydrocod, benzodiazepine",,,,Y,,,,,Y,Y,,,,,,,,,Accident,"CT (41.575155, -72.738288)","

Categories
Database Development

Need help to understand tuning up a slow SQL server query in SQL2012

For one of our databases the query like below is extremely slow. Due to security reasons I am not able to share the actual query or plan but just to give an idea how query is written is below SELECT [Id] ,[AboutMe] ,[Age] ,[CreationDate] ,[DisplayName] ,[DownVotes] ,[EmailHash] ,[LastAccessDate] ,[Location] ,[Reputation] ,[UpVotes] ,[Views] ,[WebsiteUrl] ,[AccountId] FROM […]

Categories
Mastering Development

How to make if cond on exact count?

I use PHP and ODBC, and I was wondering how to make if condition for and exact number…? $DB = $core_db->Execute("SELECT TOP (10) ID, Name, Age, Location FROM Profiles ORDER BY Name"); $num=0; while(!$DB->EOF){ if ($DB->fields[0] != 0) { echo'<div class="ID">’.++$num.'</div> <div class="name">’.$DB->fields[1].'</div> <div class="name">’.$DB->fields[2].'</div> <div class="name">’.$DB->fields[3].'</div> ‘; } $DB->MoveNext(); Now I want to use […]

Categories
Mastering Development

Copying a class instance to another with python

I have a function which returns an object of class Person, defined as: class Person: def __init__(self): self.id=None self.age=0 self.name=None def setValues(self,id,age,name): self.id=id_ self.age=age_ self.name=name_ And here is a function which returns such an object: def getTeacher(): pr = Person() pr.setValues(11,"John",30) return pr Now, I want to assign the object returned by this function to […]

Categories
Mastering Development

Populate calculated values from other sheets into new sheet

I have excel which contains four sheets (say sheet1, sheet2, sheet3 and sheet4). I want to populate calculated values and other information from (sheet1, sheet2, sheet3) to sheet4. Both sheet1, sheet2 contains ID,Name, Age, Amount whereas sheet1 is static page and sheet2 is dynamic page. sheet3 will have ID, Name, Age, Contribution. once all these […]