Questions tagged [ansi-sql]

ANSI SQL is the American National Standards Institute adopted Structured Query Language standard, developed by ISO/IEC JTC 1. It is the base for the different SQL dialects used by different DBMS vendors.

ANSI SQL is the American National Standards Institute adopted Structured Query Language standard, developed by ISO/IEC JTC 1. It is the base for the different SQL dialects used by different DBMS vendors.

SQL/PSM (SQL/Persistent Stored Modules) is the ISO standard defining an extension of SQL with a procedural language for use in stored procedures.

In Oracle PL/SQL (for stored procedures) and SQL (for queries) are two completely different languages (and are internally executed by different engines). DB2, PostgreSQL and Firebird also make clear distinction between the query language (called SQL) and the procedural language (for which every vendor uses a different name).

Microsoft SQL Server doesn't make this distinction: only T-SQL is used which covers the query language and the procedural language.

355 questions
-1
votes
1 answer

Operators on date/time fields

Is the + and - operator defined in standard sql on date/time types, for example Time, Duration, Date, Datetime, Timestamp. Here is an example from MySQL: select date '1983-09-05', time '01:02:03', timestamp '2014-01-01 01:02:03', date '1983-09-05'…
David542
  • 104,438
  • 178
  • 489
  • 842
-1
votes
1 answer

Is there an automatic way to convert Oracle's join syntax (+) to standard join syntax?

Converting from Oracle to PostgreSQL, have lots of SQL to convert from Oracle's join syntax "(+)" to standard join syntax. Is there an automatic way - tool - to do this? Barring that, are there any rules of thumb to use when doing such a…
VinceJS
  • 1,254
  • 3
  • 18
  • 38
-1
votes
1 answer

SQL-92 Selecting with the dot operator

Before it is marked as a duplicate, I am not asking If I have to specify it fully, I am why it does not matter if it is specified. Hope that clears that up. Now to the question. I'm new to SQL so I'm not sure if there is some technical term for…
JustAFellowCoder
  • 300
  • 2
  • 11
-1
votes
1 answer

SQL performance optimization: AND vs IN

Given this example table +----+------+-----+--------+ | ID | Name | Age | Exempt | +----+------+-----+--------+ | 1 | AA | 50 | FALSE | | 2 | BB | 40 | FALSE | | 3 | CC | 30 | FALSE | | 4 | DD | 65 | TRUE | | 5 | EE | 50 |…
-1
votes
2 answers

Formatting date when using CAST

I would like to use CAST to convert a DATE type to a VARCHAR2 type. DBUSER >SELECT CAST(CURRENT_DATE AS VARCHAR2(20)) THE_DATE from DUAL; THE_DATE -------------------- 09-AUG-17 However, I need the VARCHAR2 result to be formatted as 'YYYYMM'. I…
lit
  • 14,456
  • 10
  • 65
  • 119
-1
votes
1 answer

SSIS Change a date format

I have a datetime format that is displayed as the following: '13-10-2016 11:58:00' I require it to be shown as : '2016-10-13 11:58:00' How can I change the expression below in order to match this? Expression: "SELECT _sessions.session_id AS…
BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
-1
votes
1 answer

Rewrite MySQL's INSERT string in ANSI format

I have been trying use php's preg_split to rewrite mysql's sql insert statement string into general format, for instance: INSERT INTO `table_name` SET `col1`=123, `col2`='That''s a ''test case'', and that''s too.' Expected…
-1
votes
1 answer

Cross-DB LIKE function

I have to perform this query select * from mytable where number like '%11% where number is a numeric field. I found the solution for Postgres doing this: select * from mytable where CAST(number as text) like '%11% But if i try to execute this…
Domenico
  • 231
  • 1
  • 2
  • 6
-1
votes
1 answer

display month name instead of month number in mysql

Write a query to display the name of the month and the number of events scheduled in each month in the year 2013, sorted by month. Give an alias to the month name as month_name and the to the number of events scheduled as number_of_events. Name of…
Umang Agrawal
  • 43
  • 1
  • 8
-1
votes
1 answer

How do i write a case statement to subtract 5 hours from datetime if it's before day light saving and subtract 4 hours if after

I need to subtract 5 hours if the datetime falls before 03/09/2014 saving and 4 hours if it's after 03/09/2014. It's in a case statement this is what I have so far but it's only hitting the first when and not working with the second when. max( …
-1
votes
1 answer

whitespace UNION bug

This one got me the other day. What would you expect the following to return? SELECT 'X' AS line UNION SELECT 'X ' AS line Notice the space in the second SELECT. Well apparently SQL 2000 and 2005 both return 1 result. Even though its a UNION (and…
Johnno Nolan
  • 29,228
  • 19
  • 111
  • 160
-2
votes
1 answer

Is joining to the result of a select (rather than an actual table) valid ANSI standard SQL?

Microsoft SQL Server allows this (using the Pubs database). select titles.title_id, title, TotalSales from titles join (select title_id, sum(qty) as TotalSales from sales group by title_id) as ts on ts.title_id =…
RichardHowells
  • 7,826
  • 3
  • 24
  • 24
-2
votes
1 answer

How do I calculate distance between two latitude, longitude points in miles using standard SQL without trigonometry?

How do I calculate distance between two latitude, longitude points in miles using standard SQL without trigonometry?
LearningHero
  • 41
  • 2
  • 6
-2
votes
2 answers

Exist query Oracle join syntax vs ANSI JOIN syntax

When I write an exist query in ORACLE JOIN syntax like this, it works fine as expected. Select * from TableA where not exists (Select 1 from TableB where TableB.Id = TableA.TableBForeignKeyId) When i write it as ANSI JOIN syntax, it doesn't…
Curious
  • 474
  • 1
  • 8
  • 25
-2
votes
1 answer

Is there any difference between MySQL specific implementation of SQL and ANSI SQL?

Is there any difference between MySQL specific implementation of SQL and ANSI SQL? And if there is, how is MySQL SQL dialect called?
rGA145
  • 155
  • 2
  • 11
1 2 3
23
24