[Solved] How to use multiple inner joins

I see that your custumers are identified by the telephone number, i don’t think that is a good idea, since telephone number can change quite often in your custumer table, anyway this should be the query. SELECT SA.* FROM STATAMENT_OF_ACCOUNT_TBL SA JOIN OFFICIAL_RECEIP_TBL R ON SA.STATEMENT_ACC_NO=R.STATEMENT_ACC_NO JOIN CUSTUMER_TBL C ON C.CUS_TEL_NO=R.CUS_TEL_NO WHERE C.CUS_TEL_NO=’422-9418′ Ah, and … Read more

[Solved] please help me PHP and SQL [closed]

You want to create a new table that acts as a link between the subject and teacher, lets call it teacher_subject. The table should have three columns: id, subjectId and teacherId. To add a subject to the teacher, just insert a new row with the correct subjectId and teacherId. To get all the subjects that … Read more

[Solved] How to use group by in this cquery?

SELECT eav.value AS ‘unspsc’,COUNT( e.sku) FROM catalog_product_entity e JOIN catalog_product_entity_varchar eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE ea.attribute_code=”unspsccode” GROUP BY eav.value solved How to use group by in this cquery?

[Solved] Strategies for large amount of db queries for single page request [closed]

There’s no real hard limit. It will all depend on a number of factors; including the profile of your db traffic, the resources available to your db, your db architecture (replicated/distributed etc), your schema, your app design, network connectivity, your user’s expectations. The best thing to do would be to have an idea of what … Read more

[Solved] SQL Join query to return matching and non-matching record

Your problem is coming from including columns in SELECT statement from table_2 that do not have values for rows that exists in table_1. You need to change SELECT Table_2.ScriptNumber to SELECT Table_1.ScriptNumber As future reference make sure you always select all relevant columns from LEFT tables and only columns you need from RIGHT table. Otherwise … Read more

[Solved] How to select sub string in oracle?

Using substr: declare l_start number := DBMS_UTILITY.get_cpu_time; begin for i in ( with t as ( select ‘Chapter ‘ || level || ‘ Unit ‘ || level || ‘ Sect ‘ || level d from dual connect by rownum < 100000 ) select substr(d, 1, instr(d, ‘ ‘, 1, 2) – 1) chapter , substr(d, … Read more

[Solved] Current month and last month data in single row

You can use an aggregate function with a CASE expression similar to this: select itemname, sum(case when month(date) = month(getdate()) -1 then amt else 0 end) LastMonthAmt, sum(case when month(date) = month(getdate()) then amt else 0 end) CurrentMonthAmt from yourtable group by itemname; See SQL Fiddle with Demo 0 solved Current month and last month … Read more