Skip to content

Tag: sql

Postgresql merge columns

I have a main table which is like this I can merge full_name and last_name like this but I couldn’t do the same thing with the children_names column I want to select children like this but I want to add last_name filed at the end of each child like this Answer Using a scalar subquery: Yet it would be mu…

Trim Intermediate spaces in a string in Postgres

In the result, want only intermediate spaces to be removed. Need to print only first part before hypen (-) along with Percentages. Can you please help. Input String: AMAZON – 25%; SAP – XXXXX – 45%; MICROSOFT – XXX&YYY – 30% Query: Answer regexp_split_to_table can be used to …

How to split linestrings into their individual segments?

I am new to PostGIS. I have a set of (thousands) of Linestrings and associated multiple points along the line. I want to divide each line into a set of line segments consisting of only 2 points. I find a few answers, But none of the answers I want. for example https://gis.stackexchange.com/questions/21648/exp…

SQL for Calclate sum of Sales At particular time every day

Order Table.Reprpesents Order Date and Created is time at which record was inserted The laltest record in this table is at(Created value) – 05:17:38.710 Output – 2021-12-26 05:17:38.710 At this time on 26th i.e. today’s date the sales was At the same time I want to know the sales on 25th I w…

Finding who called who

I have these two tables. Subscriber table contains SubscriberID and his Phone number. NetworkP2P contents SubscriberID, to who he has called AddresseeNumber and when the call started, ended. Example data: Subscriber NetworkP2P Not all Phone numbers match the ones that Subscribers have. How would I approach th…

How do I find data from this day exactly one year ago in oracle?

Merry Christmas, I am using the below query to get the prices, but my requirement is to get the data for last one year from trunc(sysdate). i have tried using DATEADD function but its gives me an error cast(p.asof as DATE) = cast(DATEADD(Year, -1, GETDATE()) as DATE) Can anyone please help, what all changes i…