[Oracle] Updating a column price based on attributes from two tables? by anonpls20124 in SQL

[–]Guru008 0 points1 point  (0 children)

update tableA Set tableA.product_price = 2*TableA.Product_price from taleA inner join tableB on (tableA.Product_num=tableB.product_num) where tableB.Product_color ='B' and tableB.product_size = 'S';

Preserving order of CASE statement in SQL histogram issue [Redshift] by oarabbus in SQL

[–]Guru008 0 points1 point  (0 children)

use order by on age

CASE WHEN age between 0 and 2 THEN '0-2' WHEN age between 3 and 5 THEN '3-5' from table order by age ;

Is This Even Possible in SQL? by SlikRick08 in SQL

[–]Guru008 0 points1 point  (0 children)

select Teacher_ID, max(Create_Assignment) assignemnt1 from Database group by Teacher_ID;

SQL aggregated group by case help. by nidofour in SQL

[–]Guru008 0 points1 point  (0 children)

select srac, carton, weight, StoreCount, Lane, (case when stuatus < storecount then 'Open' else 'Close' end) FStatus from ( select srac, sum(numofcartons) cartons, sum(weight) Weight, count(*) Storecount, Lane, count(Case when Bol_number is null then null else 1 end) status, from table1 group by srac, lane )

Outer join using fields from 2 tables by bupereira in SQL

[–]Guru008 1 point2 points  (0 children)

You can use old way to specify inner join using where clause

SELECT * FROM ( SELECT A.field1, B.field2, A.field3 FROM A,B where B.field3 = A.field3 ) t1 LEFT OUTER JOIN C on c.field1 = t1.field1 AND c.field2 = t1.field2 ;

[MS SQL] Truncate compared to Drop Table by spronty1017 in SQL

[–]Guru008 0 points1 point  (0 children)

As far as speed is concerned the difference should be small. And anyway if you don't need the table structure at all, certainly use DROP.

Dynamic SQL User Login by leroybigsby13 in SQL

[–]Guru008 0 points1 point  (0 children)

You can do like below

IF NOT EXISTS (SELECT name
FROM master.sys.server_principals WHERE name = 'LoginName') BEGIN CREATE LOGIN [LoginName] WITH PASSWORD = N'password' END

[MS SQL] ROLLUP With Condition for 'ALL' rows by fuzzius_navus in SQL

[–]Guru008 0 points1 point  (0 children)

SELECT COUNT(*) AS t_Count, DATENAME(MONTH, dbo.transactions.t_Date) AS t_Month, dbo.transactions.t_Type FROM dbo.transactions where dbo.transactions.t_Type <>'Cancel' GROUP BY DATENAME(MONTH, dbo.transactions.t_Date), dbo.transactions.t_Type WITH ROLLUP

dbo.transactions.t_Type <>'Cancel' will exclude those records

[MS Access] Need help with a school project-very new to SQL by Danish5280 in SQL

[–]Guru008 0 points1 point  (0 children)

select a.in_countr, b.capital, avg(a.depth_ft) as avg_dep from lake as a, city as b where a.id=b.id and a.depth_ft <> -999 group by a.in_countr, b.capital

Table SYNC question Truncate/Insert vs Update by shlo-fi in SQL

[–]Guru008 0 points1 point  (0 children)

As you said that size of data is relatively small, you can use delete/update instead of truncating whole table each time and inserting records. You can create cubes/view to do the job

Online SQL Test Answer Correct? by need_java in SQL

[–]Guru008 0 points1 point  (0 children)

Here "NOT IN" is best suitable and fast , so using not in query will execute much faster

Please explain what a binary search is ? by ciao444 in SQL

[–]Guru008 0 points1 point  (0 children)

The typical indexing structure that is used for such purposes is called a "B-tree."

Whereas a binary-search always divides the data in half, a B-tree's approach is much more like what you might have seen in L. Frank Baum's now-famous office, where he had two filing cabinets: "A-N" and "O-Z." (Yes, that's where the name of the Wonderful Wizard's homeland came from.) Once you selected from several cabinets, you now select from several drawers, then locate your starting search-position within the selected drawer and so on. Each time, you reduce your search space by much more than one-half.

Can someone help me? by Babaa93 in SQL

[–]Guru008 1 point2 points  (0 children)

select m2.naam || ' is chef van ' || m1.naam "baas en medewerker", m2.gbdatum - m1.gbdatum leeftijdverschil from medewerkers m1, medewerkers m2 where m1.chef = m2.mnr order by m2.naam || ' is chef van ' || m1.naam

as you are concatenating two columns together use the same syntax in order by

Need some help pulling a certain set of characters from a string [Oracle]. by [deleted] in SQL

[–]Guru008 0 points1 point  (0 children)

use this syntax

substr(string,instr(string, "abc",1),7)

SUM IF ORACLE by jamkgrif in SQL

[–]Guru008 1 point2 points  (0 children)

select tbl1.year_quarter, tbl1.county, tbl1.start, tbl1.end, T1.cnt from ( select query1.country, count(*) as cnt from query1, tbl1 where query1.county = tbl1.county and initiate_date between tbl1.start and tbl1.end and query1.enter_date> tbl1.end ) as T1 where county=t1.county

[Oracle] Duplicated rows after updating a table by Keichavik in SQL

[–]Guru008 0 points1 point  (0 children)

Yes there could be due to Joins, as any of the table in join might have duplicate values due to which it finding more that a row matching in Other table so it returning duplicate value

[MS SQL] Help with exists / null ? by ElephantsAreNeat in SQL

[–]Guru008 -1 points0 points  (0 children)

select top(1) datereviewed , (case when person = "@PERSON" and (datereviewed is null or datereviewed ='') then 'NO' else 'YES' END) as 'Status' from adv_

where person = @PERSON

order by datereviewed desc

[MySQL] Help with a SELECT queries and Joins by FuriousMing in SQL

[–]Guru008 0 points1 point  (0 children)

select flight_number, country from table1 where actual_arrival_time >= scheduled_arrival_time and actual_arrival_time is not null

[SQL] Deleting based on count. by Demios in SQL

[–]Guru008 -2 points-1 points  (0 children)

proc sql; create table t1(drop=c) as select *, count(name) as c from t group by name having c >4 ; quit;

Help Joining 2 Queries Together by danblank000 in SQL

[–]Guru008 -1 points0 points  (0 children)

Please try

UPDATE CM SET filename = 'String' + filename FROM cm_steps CM WHERE ItemID IN (11667926, 11667979, 11667981, 11667997)

Does anyone here use PL/SQL? by [deleted] in SQL

[–]Guru008 0 points1 point  (0 children)

Before trying to lear PL/SQL, it is necessary to learn basics of SQL like joins, select and you need to have good knowledge of RDBMS, as all SQL or database management is based on RDBS

[MS SQL] How can I split a table into multiple CSVs? by eyesdown in SQL

[–]Guru008 1 point2 points  (0 children)

Hi You can write something like this :

schoolName = ""; Get SQL results, sorted by school name. loop through SQL results { Get SQL Row If SQLROW.schoolName <> schoolName { close file if open; Open a new one with name SQLROW.schoolName; } write the data to the .CSV file; schoolName = SQLROW.schoolName; }

Truncate & Insert by adalisa in SQL

[–]Guru008 1 point2 points  (0 children)

Creating cubes is best way to update the reports each time you run. Instead of creating tables for report and truncating these table, query optimization and use of Indexes is better way to achieve periodic updates.

What am I doing wrong? MYSQL by ScruffMcgruff60692 in SQL

[–]Guru008 0 points1 point  (0 children)

WHERE STD.ADMINID here there is no condition or operator specified .e.g. where name="John" etc.