How to display following display table using oracle? [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Link http://s17.postimg.org/pdftjpl1r/Event.png
I have above two table.I want to display third table using oracle. I know display those data using java,vector and other stuff.But couldn't code correct oracle code.In the above display table shows data which are >=SYSDATE.

I think it is something like this:
select e.event_name,
min(dt.start_date) as start_date,
min(dt.start_date)||'-'||max(dt.end_date) as FromTo
from event e join
date_table dt
on e.e_id = dt.e_id
group by e.event_name;
You may need use to_char() to convert date/times to the right format. You don't specify wht the types are in the data, so it is hard to say what needs conversion.

Related

SQL LIKE doesn't find obvious matches [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm writing the following SQL query:
SELECT *
FROM OS
WHERE OS.VERSION LIKE '%1%';
In my table there are rows with char 1 in it. However, it returns an empty result.
I changed a little bit the LIKE clause to different values, but it still doesn't work.
What can I do to fix that?
Try double-quotes and * for wildcards. You are using Oracle syntax instead of Access syntax.
LIKE operation can't be used with columns of integer type. I assume that OS.Version is of integer type?
Edit1:
If you are referring to MS Access then you have to do the LIKE with stars (*) instead of %.

finding the word like in a sql query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string like this:
i would like to go to office, and i would like to go to market
My question is: how many times the word like occurs in the string?
Please write a query.
You can use regexp_count:
SELECT REGEXP_COUNT('i like to go , and i would like market', 'like')
FROM DUAL;
The word "like" occurs twice in the string you posted.
The following is a query:
SELECT *
FROM SOME_TABLE
WHERE SOME_VALUE = SOME_OTHER_VALUE
Share and enjoy.

Datatype supported in Oracle but not in Excel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am writing a macro which pulls data from Oracle and displays in Excel. In Oracle DB we have a custom table with a column Named "Calculated_Quantity". The datatype of this column is BINARY_DOUBLE.
When I query for this column in Oracle using SQL developer I am able to view the data. However when I write the same query in Excel macro, I get the error as "Data Type is not Supported".
Any suggestions what do I need to do here. If needed I can post my query here.
Thanks,
You should use CAST (or CONVERT for some DBMSs) to convert the data to a supported datatype.
SELECT
CAST(CALCULATED_QUANTITY AS NUMBER(10)) AS Qty
FROM
DW_STG_FSN.SAMPLE

How to concat values which retrieved from database [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am executing this query in SQL Server 2008
SELECT (CONVERT(DATE, GETDATE()))
and it shows the result 2013-07-22.
I need to print this result as 22713, where 22 is the date 7 is the month 13 is the year.
How could I do this?
SELECT CAST(DATEPART(dd,GETDATE()) as varchar(10))
+CAST(DATEPART(mm,GETDATE()) as varchar(10))
+RIGHT(CAST(DATEPART(YY,GETDATE()) as varchar(10)),2)
SQLFiddle demo
1) It bad practice use SQL for string operation. More right external tools
2) I use other RDBMS. Below query work with it:
select (extract(day from ua.stamp))||(extract(month from
ua.stamp))||(extract(year from ua.stamp)) from useractions ua
Furthemote, this link can help you:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/55d23bb0-6e1e-4a03-9bed-94e7c755ec4d/get-the-day-from-date-value-in-sql-server
You could read the string, go over it with a tokenizer, split it and put it back together the way you want it to be. What language are you using?

Get me a SQL quesry to check whether the two table data contents are equal? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am having two table A and B of same structure.Both tables is loaded with data.I just want the mismatched row of two tables.,,
I'm certain you could do some gigantic JOIN query for each column and then issue a NOT IN over the result but a simple, pragmatic solution is to:
Write a query that orders the data on several columns (or all)
Export the query executed on each table to a separate text file
Use diff to compare the files with each other
Depending on the RDBMS vendor you may have other options you could consider as well.