This question already has answers here:
How to select data from non-table in Firebird?
(1 answer)
Use Alias in Select Query
(3 answers)
Use column alias in same select [duplicate]
(2 answers)
Closed 11 months ago.
I have in my Access .mdb
SELECT a * b AS c, c * d AS e
I must translate this clause to Firebird.
Any hint?
Using SELECT without a FROM clause is non-standard in the SQL language. A few implementations allow it (e.g. Microsoft Access, SQL Server, and MySQL), but others do not.
Firebird is one of those that implement standard SQL, so you must provide a FROM clause, and reference a table with at least one row, or else you get no result.
http://www.firebirdfaq.org/faq30/ says:
You can use the RDB$DATABASE which is a single-row table, and part of each database's metadata:
select current_timestamp from RDB$DATABASE;
Any other table with at least one row could be used, but the point is that RDB$DATABASE is sure to be present.
Related
This question already has answers here:
When do Postgres column or table names need quotes and when don't they?
(2 answers)
Are PostgreSQL column names case-sensitive?
(5 answers)
Closed 3 months ago.
A SQL coding challenge provided a database; every table was accessible when passed as a string using double quotes and not when passed as a word as I am normally used to.
This did not work:
SELECT * FROM Athletes;
Error message: relation does not exist.
But this worked and I don't understand why:
SELECT * FROM "Athletes";
Was this defined during the database creation? Or is this from PostgreSQL?
This question already has answers here:
How to split comma-separated values?
(5 answers)
Split values in parts with sqlite
(2 answers)
Closed 12 months ago.
I have been trying to convert split_string syntax to SQLite from SQL Server. I couldn't find any alternative to do that. can anyone please help me to do that.
SELECT row_number () over (order by (select 0)) rn, value
FROM string_split(Nav_Path,''/'')
This is the SQL query that needs to write in SQLite. There is syntax error saying
Transaction ERROR: sqlite3_prepare_v2 failure: no such table: string_split
Thank you
This question already has answers here:
Referring to a Column Alias in a WHERE Clause
(9 answers)
Closed 1 year ago.
I am using a simple select statement and creating a column using a CONCAT function and labeling the column as Filter.
Why is the new column not being recognized?
Error message states
Invalid Column Name - Filter
You can't refer to column aliases in the where clause as the where is processed before the alias is materialised.
There are several workarounds, and assuming SQL Server you can do
select *
from table t
cross apply (values(concat(columna,columnb)))c([filter])
where [filter]='something'
Also note that the performance won't be great on large data sets since this criteria is non-sargable
This question already has answers here:
Creating temporary tables in SQL
(2 answers)
Closed 7 years ago.
How to create temporary table using select into in PostgreSQL. For example in SQL Select * into temp_tab from source_tab;
You can try to use Create Table As command like this:
CREATE TEMP TABLE mytable AS
SELECT * from source_tab;
From the docs:
This command is functionally similar to SELECT INTO, but it is preferred since it is less likely to be confused with other uses of
the SELECT INTO syntax. Furthermore, CREATE TABLE AS offers a superset
of the functionality offered by SELECT INTO.
The CREATE TABLE AS command allows the user to explicitly specify
whether OIDs should be included. If the presence of OIDs is not
explicitly specified, the default_with_oids configuration variable is
used.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?
I've been tasked with reviewing some SQL stored procedures and have seen many that look like the following:
SELECT
X, Y, Z
FROM
Table
WHERE
1 = 1
ORDER BY
X
Why would someone use '1 = 1' for the where clause?
Thanks!
It's common in dynamic SQL, in order to append additional criteria to a WHERE clause. Otherwise, it's useless and it is ignored by the optimizer.
possibly to dynamically add conditions to the where clause.