Question

In: Computer Science

Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create...

Please write the SQL statement for the following. I am using the Adventurework2014 database.

1. Create a login for AdventureWorks employees. An employee login should be composed of the first letter of a person's first name combined with their last name. In addition, the login should be all lower case characters. All the required information is located in Person.Person table. Employees can be identified by "EM" value in the PersonType field. The output should include BusinessEntityID, first name (FirstName), last name (LastName), and EmpLogin alias for the login column. **Hint use the substring fuction which takes the following format:

- expression: is a character, binary, text, ntext, or image expression

-start is an integer of bigint expression that specifies where the returned characters start. (The numbering is 1 based, meaning that the first character in the expression is 1). if start is less than 1, the returned expression will begin at the first character that is specified in expression. In this case, the number of characters that are returned is the largest value of either the sum of start + length -1 or 0. If start is greater than the n umber of characters in the value expression, a zero length expression is returned.

-length - is a positive integer of bigint expression that specifies how many characters of the expression will be returned. If length is negative, an error is generated, and the statement is terminated. If the sum of start and length is greater than the number of characters in expression, the whole value expression beginning at start is returned.

2. From Sales.SalesOrderHeader table, list all orders (SalesOrderNumber, OrderDate) that were placed in June of 2011. Use date manipulation functions.

Please only answer if you know the correct answer. I will give a thumbs up if the answer is correct and down if incorrect.

Solutions

Expert Solution

Query 1:

Oracle:

select businessentityid,firstname,lastname,lower(substr(firstname,0,1)||lastname) as emplogin
from person
where persontype='EM';

Sql server:

select businessentityid,firstname,lastname,lower(concat(substring(firstname,1,1),lastname)) as emplogin
from person
where persontype='EM';

Output:

Query 2:

Oracle:

select salesordernumber,orderdate
from salesorderheader
where to_char(orderdate,'MM')='06'
and to_char(orderdate,'YYYY')='2011';

Sql Server:

select salesordernumber,orderdate
from salesorderheader
where datename(month,orderdate)='June'
and year(orderdate)='2011';

Output:


Related Solutions

Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft Access, Oracle, or MySQL) as indicated by your professor. After creating the database – populate it with some data (could be made up). SQL syntax and the DB application will be discussed and taught in class. This is the final deliverable of the group project. Assignment is due by the due date as indicated by your professor. *Make sure to submit the completed database...
Please create the SQL queries using the lryics database under question 4 and use "select *...
Please create the SQL queries using the lryics database under question 4 and use "select * from..." after each query to show the effects of your data manipulation query. Thanks for help 1. The title 'Time Flies' now has a new track, the 11th track 'Spring', which is 150 seconds long and has only a MP3 file. Insert the new track into Tracks table (Don’t hand-code any data for insert that can be looked up from the Titles table). 2....
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2. 10. Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number...
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as if it were being added to MySQL (please give explanations for each line of SQL code and a copy of the code as it would be entered into the query by itself: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
So currently I am working on some SQL with python which is linked to my database...
So currently I am working on some SQL with python which is linked to my database and I am stuck on a split problem. So in the program it connects to the database and then next you input either list, add, update, remove or allocate. So lets say I want to add a new data into the database you just need to write: update -name='Ava - #2' -class=2. After you type this there is a variable called val which does...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
Using SQL create a new database called school_app. Create a student table with fields id (auto...
Using SQL create a new database called school_app. Create a student table with fields id (auto increment), first_name, last_name. Create a course table with fields id (auto increment), course code (such as ITC or MTH), and course number (such as 100 or 295). Note that the relationship between student and course is many-to-many (n:m). Create a join table called student_course that implements the n:m relationship with fields id (auto increment), student_id, course_id, and grade (which has values 0, 1, 2,...
Hello, I am using BASH. I need to write a conditional statement using grep. I want...
Hello, I am using BASH. I need to write a conditional statement using grep. I want the computer to echo true if it detects any numerical character in the first line of StrepList.txt. However, the computer tells me that "grep: [0-9]: No such file or directory" if (head -n 1 StrepList.txt | grep -o [0-9] -eq TRUE);then echo "Contains numbers" else echo "No numbers" fi
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT