How to insert dummy rows into sql without using an insert query?
I have the following request
select '2016' as yr,warehouse as product,sum(answertext) p1 ,
round((sum(abc)/(select sum(abc) from [table 1])*100),2) p2
from [table 1]
group by warehouse
order by p1 desc
limit 10
which shows the following output
yr product prodnum prodper
2016 Harness Extra 94427 10.4
2016 Lumax 54534 9.6
..
...
..
...
..
..
..
2016 Capreno 534533 4.6
Now I need to manually insert dummy values during 2015 and 2014 with custom values for prdonum and prodper that I have in another word sheet how to do this in one query? any help would be great? it should be in the following format
yr product prodnum prodper
2016 Harness Extra 94427 10.4 // from table
2015 Harness Extra 32453 5.7 <- custom value to be inserted
2014 Harness Extra 21215 2.3 <- custom value to be inserted
2016 Lumax 78994 8.76 // from table
2015 Lumax 43435 4.77 <- custom value to be inserted
2014 Lumax 15522 3.55 <- custom value to be inserted
..
..
..
<totally 30 rows>
+3
source to share
1 answer
If you have this in another table, perhaps use a union statement?
Select * from
(
select '2016' as yr,warehouse as product,sum(answertext) p1 ,
round((sum(abc)/(select sum(abc) from [table 1])*100),2) p2
from [table 1]
group by warehouse
UNION ALL
select '2015' as yr,warehouse as product,sum(answertext) p1 ,
round((sum(abc)/(select sum(abc) from [table 1])*100),2) p2
from [table 2]
group by warehouse
UNION ALL
select '2014' as yr,warehouse as product,sum(answertext) p1 ,
round((sum(abc)/(select sum(abc) from [table 1])*100),2) p2
from [table 3]
group by warehouse
)a
order by p1 desc
0
source to share