Libraries Search
Showing posts with label Basic syntax. Show all posts
Showing posts with label Basic syntax. Show all posts

JavaScript - Syntax Learn Libery

JavaScript can be implemented using JavaScript statements that are placed within the <script>... </script>.

You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the <head> tags.

The <script> tag alerts the browser program to start interpreting all the text between these tags as a script. A simple syntax of your JavaScript will appear as follows.

<script ...>
   JavaScript code
</script>
The script tag takes two important attributes −

Language − This attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute.

Type − This attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript".

So your JavaScript segment will look like −

<script language="javascript" type="text/javascript">
   JavaScript code
</script>
Your First JavaScript Script
Let us take a sample example to print out "Hello World". We added an optional HTML comment that surrounds our JavaScript code. This is to save our code from a browser that does not support JavaScript. The comment ends with a "//-->". Here "//" signifies a comment in JavaScript, so we add that to prevent a browser from reading the end of the HTML comment as a piece of JavaScript code. Next, we call a function document.write which writes a string into our HTML document.

This function can be used to write text, HTML, or both. Take a look at the following code.

<html>
   <body>
      <script language="javascript" type="text/javascript">
         <!--
            document.write("Hello World!")
         //-->
      </script>
   </body>
</html>
This code will produce the following result −

Hello World!
Whitespace and Line Breaks
JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs. You can use spaces, tabs, and newlines freely in your program and you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.

Semicolons are Optional
Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements are placed on a separate line. For example, the following code could be written without semicolons.

<script language="javascript" type="text/javascript">
   <!--
      var1 = 10
      var2 = 20
   //-->
</script>
But when formatted in a single line as follows, you must use semicolons −

<script language="javascript" type="text/javascript">
   <!--
      var1 = 10; var2 = 20;
   //-->
</script>
Note − It is a good programming practice to use semicolons.

Case Sensitivity
JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.

So the identifiers Time and TIME will convey different meanings in JavaScript.

NOTE − Care should be taken while writing variable and function names in JavaScript.

Comments in JavaScript
JavaScript supports both C-style and C++-style comments, Thus −

Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.

Any text between the characters /* and */ is treated as a comment. This may span multiple lines.

JavaScript also recognizes the HTML comment opening sequence <!--. JavaScript treats this as a single-line comment, just as it does the // comment.

The HTML comment closing sequence --> is not recognized by JavaScript so it should be written as //-->.

Example
The following example shows how to use comments in JavaScript.

<script language="javascript" type="text/javascript">
   <!--
 
      // This is a comment. It is similar to comments in C++
 
      /*
      * This is a multiline comment in JavaScript
      * It is very similar to comments in C Programming
      */
 
   //-->
</script>

Create the Following Tables With The Specified Data

Sales_People

Snum
Sname
City
Comm
1001
Peel
London
0.12
1002
Serres
San Jose
0.13
1004
Motika
London
0.11
1007
Rifkin
Barcelona
0.15
1003
Axelrod
Newyork
1.10


Customers

Cnum
Cname
City
Rating
Snum
2001
Hoffman
London
100
1001
2002
Gio-Vanne
Rome
200
1003
2003
Liu
San Jose
300
1002
2004
Grass
Berlin
100
1002
2006
Clemens
London
300
1007
2007
Parera
Rome
100
1004


Orders

Onum
Amt
O-Dt
Cnum
Snum
3001
18.69
10_3_94
2008
1007
3003
767.19
10_3_94
2008
1001
3002
1900.1
10_3_94
2007
1004
3004
5160.45
10_3_94
2003
1002
3006
1098.16
10_3_94
2008
1007
3009
1713.23
10_4_94
2002
1003
3007
75.75
10_4_94
2004
1002
3008
4723.00
10_5_94
2006
1001
3010
1309.25
10_6_94
2004
1002
3011
9891.88
10_6_94
2006
1001







Queries


1.      Display all cols of all Sales People
2.      Display all snum without duplicate from all orders.
3.      Display names and comm of all sales people from London.
4.      Display all customers with the rating of 100
5.      Produce Order No, amount, dt for all rows in the order table
6.      All orders for more than Rs. 1000
7.      Display name and city of all sales people in London with comm. above 0.1
8.      All customers excluding those with rating less than or equal to 100 unless they are located in Rome.
9.      Display sales people either in Barcelona or London
10. All Salespeople with comm. between 0.10 to 0.12
11. All customers with null values in city column
12. All orders taken on Mar 10 and Aril 10  
13. All customers services by Peel or Motika
14. All customers whose names begin with ‘C’ from customers
15. All orders excluding those with zero or null values in amt field
16. Count the number of sales people currently listing orders in order table
17. Largest orders taken by each sales person date wise.
18. Largest order taken by each sales person with order value more than 3000 date wise.
19. Which day had the highest total amount ordered?
20. Count all orders for Oct 3
21. Count the number of different non-null city values in customer table.




22. Select each customer's Smallest Order WITH CUSTOMERS NAME.
23. First customers in Alphabetical order whose names begin with ’G’.
24. Get the output like:
   “On Dd Mm Yy there are _____ orders.”
25. Assume that each sales person has 12% comm. Produce order no, salesperson no and amount of sales person comm. for that order.
26. Find highest rating in each city. Display the output in the following form:
“For the city <city name> the rating is <rating>.”
27. All combination of sales people and customers for each order after the order number.
28. Names of all customers matched with the sales people serving them.
29. List each order no followed by the name of the customer who made the order.
30. Names of sales person and customers for each order after the order no.
31. Produce all customers serviced by sales person with a comm. above 12%
32. Calculate the amt of the sales person’s comm. on each order with a rating above 100.
33. Find all pairs of customers having the same rating with each pair coming once only.
34. Policy is to assign three sales people to customer, one at each of the 3 ratings. Display all such combinations.
35. Display all customers located in cities where sales man serves has customer.
36. Find all pairs of customers served by a single salesperson.
37. Produce all pairs of salesperson who live in the same city. Exclude combination of salesperson with themselves as well as duplicate with order reverse.
38. Produce names and cities of customers with the same rating as Hoffman.
39. Extract all orders of Motika
40. Produce all orders credited to same salesperson that serviced Hoffman.
41. All orders those are greater than the average for 4 Oct.
42. Find avg comm. of salesperson of London
43. Find all orders attributed to sales person in London.
44. Extract comm. of all sales people serving customers in London.
45. Find all customers whose snum is 1000 above the snum of Seres.
46. Count the customer with rating above San Jose average.
47. Obtain all orders for the customer name Liu.
48. Produce the name and rating of all customers who have above average orders.
49. Find total amt in orders for each sales person for whom this total is greater than the amt of the largest order in the table.
50. Find all customers with orders on 3 Oct.
51. Find names and no of all salesperson that have more than one customer.
52. Check if the correct salesman was credited with each sale.
53. Find all orders with the above average amt for their customers.
54. Display all the salespersons name with smallest length name first and so on…
55. Display all the records with city field containing nothing.
56. Display all the record with city field indicating ‘****’ where city is null.
57. Display all the records with comm indicating 0 where comm is not specified.

The INVOICE Table www.library82.blogspot.com !

ClientName          VARCHAR2(25)
InvoiceDate          DATE
Amount                                 NUMBER(9,2)

'ELBERT TALBOT'
'23-OCT-1901'
5.03
'JOHN PEARSON'
'09-NOV-1901'
2.02
'DICK JONES'
'12-SEP-1901'
11.12
'GENERAL STORE'
'09-NOV-1901'
22.10
'ADAH TALBOT'
'17-NOV-1901'
8.29
'GENERAL STORE'
'01-SEP-1901'
21.32
'ADAH TALBOT'
'15-NOV-1901'
7.33
'GENERAL STORE'
'04-OCT-1901'
8.42
'KAY WALLBOM'
'04-OCT-1901'
1.43
'JOHN PEARSON'
'13-OCT-1901'
12.41
'DICK JONES'
'23-OCT-1901'
4.49
'GENERAL STORE'
'23-NOV-1901'
40.36
'GENERAL STORE'
'30-OCT-1901'
7.47
'MORRIS ARNOLD'
'03-OCT-1901'
3.55
'ROLAND BRANDT'
'22-OCT-1901'
13.65
'MORRIS ARNOLD'
'21-SEP-1901'
9.87
'VICTORIA LYNN'
'09-OCT-1901'
8.98
'GENERAL STORE'
'22-OCT-1901'
17.58


Find the total of amount for the day
Find the total of amount for the client
Find the total of amount

Find maximum amount
Find minimum amount
Find maximum amount for client
Find minimum amount for client

Find no of record present in table
Find no of record present for each client
Find no of record present for each date



List uniqe Invoice date
List customer name
List all invoice according to invoice date
List all invoice according to amount
Display all invoice date wise, client arranged.
Display all invoice client wise, amount wise arranged.
List invoice of November month
List invoice of December month
List invoice with amount in range 10 to 15
List invoice where client name starts with 'M'
List invoice where client name is   'ADAH TALBOT' or 'GENERAL STORE' or 'KAY WALLBOM'List List invoice where client name is 'JOHN PEARSON' or 'DICK JONES' or 'GENERAL STORE'
List invoice which contain word 'TALBOT' in column client name
Make client name 'GENERAL MARCHANT' from 'GENERAL STORE'