background preloader

Sql query

Facebook Twitter

SQL INSERT Statement. The INSERT Statement is used to add new rows of data to a table. We can insert data to a table in two ways, 1) Inserting the data directly to a table. Syntax for SQL INSERT is: INSERT INTO TABLE_NAME [ (col1, col2, col3,...colN)] VALUES (value1, value2, value3,...valueN); col1, col2,...colN -- the names of the columns in the table into which you want to insert data. While inserting a row, if you are adding value for all the columns of the table you need not specify the column(s) name in the sql query. INSERT INTO TABLE_NAME VALUES (value1, value2, value3,...valueN); For Example: If you want to insert a row to the employee table, the query would be like, INSERT INTO employee (id, name, dept, age, salary location) VALUES (105, 'Srinath', 'Aeronautics', 27, 33000); NOTE:When adding a row, only the characters or date values should be enclosed with single quotes.

If you are inserting data to all the columns, the column names can be omitted. Inserting data to a table through a select statement. Create table and insert data by sql query. Slides6.pdf (application/pdf Object) Ch5_SQL.pdf (application/pdf Object) SQL Query" SQL query March 17, 2002 - 3pm UTC Reviewer: munz from reston, usa Excellent as usual Why r u Using Distinct and then First_value here March 19, 2002 - 7am UTC Reviewer: Pascal from germany,HH Refer to ur Query just compied from above: select item_no, sum(qty) 2 from ( 3 select distinct item_no, bin, 4 first_value(qty) over(partition by item_no, bin 5 order by effective_date desc) qty 6 from t 7 ) 8 group by item_no 9 / I have been reading ur Book and been trying these Analytic Functions myself..but sometimes i had to use Distinct to get correct results ---otherwise , it doesn't work..

Followup March 19, 2002 - 9am UTC: Well, I'm actually using the ANALYTIC function and then the distinct. Query June 24, 2003 - 4pm UTC Reviewer: mo Followup June 25, 2003 - 11am UTC: actual query June 24, 2003 - 5pm UTC Tom: Please disregard previous query. here is the actual one. I think that is the same answer as the other one. June 25, 2003 - 11am UTC Tom: Thanks a lot. Followup June 25, 2003 - 7pm UTC: Great.