I Have a couple of tables as per below Position table Id PositionName 1 Developer 2 Analyst 3 Tester Employee table Id Name Positions 1 John 1,2 2 Lisa 3 3 Smith 1 4 Willow NULL 5 Burly 2,3 …
Tag: sql
Hive – Query to get Saturday as week start date for a given date
I have an requirement in hive to calculate Saturday as week start date for a given date in hive sql. Eg) I tried using pmod and other date functions but not getting desired output. Any insight is much appreciated. Answer Hive offers next_day(), which can be adapted for this purpose. I think the logic you want…
Update all rows with different values. When where conditions differ
Apologies in advance for the confusing title, but couldn’t quite find the right way to summarize it in the title. I have a table in SQLite Studio with four columns ID, Name, Tm (which means team) and TmID (TeamID) and 326 rows Obviously the query above allows me to update each row where the team is R…
Lookups in for single PostgreSQL table suddenly extremely slow after large update
I have a messages table with a few million records in it. My Rails app includes a query on most pages to count the number of unread messages to show the user. This query – and all queries of the messages table – is unchanged and was working fine until yesterday. Yesterday, I created a new messages…
PHP select query print out numerous items from database [closed]
My Table So I want it to print off like Coffee Name: ColumbianPrice: 7.99 Total Sold: 3 Total earnings: 23.9 And then to repeat for each type of coffee Is there any web pages that allow me to do this …
Convert character to number, like +00005 to 5
We have the fixed format data and it has the number with plus/minus sign, like +00005 or -00005. We’d like to convert it to number but Redshift seems not to allow implicit conversion. So, I temporarily use to_number(replace(<numbercolumn>, ‘+’, ”),’99999′) But I guess…
SQL query to delete records when the difference between two dates is greater than a certain value
I would like to delete records when the difference between SYSDATE and a TIMESTAMP (6) field of my table is greater than 10 days. I have created the following query: but i get the following error: am i creating the query correctly? Answer am i creating the query correctly? No, you cannot refer to an alias in …
SQL get total sellers of product category
I have like this database tables: Table categories Table products Table product_varieties I have query to get price min, max and avg in each category: Now I need get total users (sellers) of each category by editing my current query. I tried like this: But my query not work and return error with message: How …
Trigger Not Running Check Whether it is correct or not? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question This is my trigger and its running perfectly with the help of stackoverflow.com I edit my ques…
How to select data where more than one column is populated
I have a sample table, called [SAMPLES] which I’ve added multiple columns to the end for different types of lab analysis results, however for the majority of samples only one analysis has been completed. I want to be able select only the samples where more than one analysis has been completed on the sam…