Skip to content
Advertisement

Tag: sqlplus

Why are these 2 queries giving different outputs?

Query no 1:- The Query 1 gives me the following output:- Query no 2:- The Query 2 gives me the following output:- Answer Summary: The AND operator has higher precedence than the OR operator. To fix it, use brackets around the OR expression. AND has higher precedence than OR so your first query is the equivalent of (with added brackets

SQL – How to print calculated datetime result

If a.modified_datetime is ‘2021/10/01 13:00:00’ and b.modified_datetime is ‘2021/10/01 12:30:00’, the result of this query would be: However, I run this query via sqlplus, it returns What’s wrong with this query, or need to set some options to sqlplus? Answer it is stored in a date column As @a_horse_with_no_name pointed out in a comment, calling to_date() on a value that

Getting not valid month in Oracle sql

I have a table called Transactions that has a column called trans_date. I am just trying to do a simple query in the SQL*Plus command window The query is When I run this query I get not valid month and there is a little * under trans_date. Most of what I have read suggests the query is right but I

Order by the Compute of Count in SQL

Hi I get the results that I’m looking for however, I want to order it by the count from the compute. Anyone have any ideas. Answer One approach is to use window functions to calculate and order by that value. The following orders the result by n descending, but doesn’t include n in the final SELECT list. I kept your

spool to .csv file using for loop

need to spool output into .csv file using loop, fyi…I have data in 4 diff partition. but no sure how to proceed. code be like. result:- not sure if I am spooling properly, also please check the index variable of for loop in used correctly in my select statement. Answer You don’t need 4 different queries, just list all your

Columns in SQLPlus report display longer than database column size

I have a number of sql reports that used to work fine. Recently however they have started to be outputted with the column widths being longer than they should. According to Oracle’s documentation if a column in an sql report has no explicit “COLUMN” definition at the start of the report, eg ‘column example_col heading “Eg col” format A50’, it

SQLPLUS : set sqlformat insert : SP2-0158

I want to export all my datas as insert statement. In Sql Developer, the command “set sqlformat insert” work very well… but when I want to use it on sqlplus, I have this error message : SP2-0158 unknown SET option “sqlformat” This command work when it’s use on a script but i’ve made a script : I’ve try the same

Advertisement