SQL

Creation of a temporary table in postgres

I’m trying to create a temporary table in Postgres (to speed up joining, as there will be a lot of similar queries throughout a session). The SQL that will be called at the beginning of a session is the following: CREATE TEMPORARY TABLE extended_point AS SELECT ( point.id, local_location, relative_location, long_lat, region, dataset, region.name, region.sub_name, color, type) FROM point, region,…
Read more

SQL Requests. Working with text boxes

Not working request. What could be the problem? Before that he wrote through CommandText, all worked well. Code: private void buttonSearch_Click(object sender, EventArgs e) { string constring = @”Data Source=(LocalDB)v11.0;AttachDbFilename=C:UsersHomePCDesktopLab2 DBLab2 DBResearchDB.mdf;Integrated Security=True”; using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand(“SELECT * FROM ‘”+comboBox1.SelectedItem.ToString()+”‘ WHERE ‘”+ comboBox2.SelectedItem.ToString() +”‘ = ‘”+ textBox1.Text +”‘”, con)) { cmd.CommandType…
Read more

How to answer this hard sql?

The IT Manager of Chinook is interested to find out which email providers their customers are associated with. Write a single SQL statement to generate a list with 2 columns named Email Provider and No. of Customers. The email provider should be displayed in all upper cases (e.g. GMAIL, YAHOO) and such information could be obtained from the email address…
Read more

How to echo all rows with all columns?

Can I echo all rows ? here’s what my script is: $options=mysql_query(“SELECT col1, col2, col3, col4 FROM table1”); while($allrowsandcolumns=mysql_fetch_array($options)) { $options1=mysql_query(“SELECT * FROM table2 where id=$allrowsandcolumns”); } while($rows=mysql_fetch_array($options1)) { echo $rows[‘name’]; } My Error says Notice : Array to string conversion in line 3 of code above IM guessing its because this is not how you display all columns &…
Read more

Whats are the consequences/side effects of deleting STALE records from Oracle DB with Large Data?

This may sound like a silly questions. However, one of the easiest solutions to keep my data consistent is to delete STALE records from my DB Table. My table has millions of row. Can anyone please tell me consequences/side-effects of deleting data from DB. This DB will be heavy read and medium writes. Any predictions or 2 cents here before…
Read more

multiple joins and group by in codeigniter

I’m using Codeigniter, what I want to do is a query that returns users by groups. A group can have one or more users, here examples of the tables: groups table users table users_by_groups table id id id_group id_user 1 10 1 10 2 11 1 11 3 12 1 12 2 11 3 12 the query I made: public…
Read more

SQL:Server How do I consolidate case when statements that have (SUM)

Hello I want to consolidate this query…. [select substr(prtmst.typcod, 1, 3) Article_Type, case when substr(prtmst.typcod, 1, 3) like ‘A%’ then ‘Accessories’ else case when substr(prtmst.typcod, 1, 3) = ‘L02’ then ‘Spirit’ else case when substr(prtmst.typcod, 1, 3) = ‘L03’ then ‘Wine’ else case when substr(prtmst.typcod, 1, 3) = ‘L04’ then ‘Beer & Soft Drinks’ else case when substr(prtmst.typcod, 1, 3)…
Read more